jmkotman
asked on
Number to an Array C#
If I have a number, say 00153 which i have read in and it is set to a string variable 'number1'.
So number1 = 00153;
How do i convert that into an array so that each numbers is a diffrent element in the array.
So number1 = 00153;
How do i convert that into an array so that each numbers is a diffrent element in the array.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"00153".ToCharArray() will give you a char array
if the variable is strTest then
char[] fields = strTest.ToCharArray();
if the variable is strTest then
char[] fields = strTest.ToCharArray();
string number1 = "00153";
string[] digits = new string[number1.Length];
for (int i = 0; i < number1.Length; i++)
{
digits[i] = number1.Substring(i, 1);
}
foreach (string digit in digits)
{
System.Diagnostics.Debug.W
}
Or did you want an Array of ints?