Isaac
asked on
unassigned error
What am I doing wrong? I get the following error:
Use of unassigned local variable 'newArry'
Console.WriteLine("------- ---------- ---------- ---------- ---------- ---------- -");
string noZero = "1,3,5,6,7,9,10,14,16,17";
string[] leadingZeros = noZero.Split(',');
string[] newArry;
int i = 0;
foreach (string y in leadingZeros)
{
if (y == "1" || y == "2" || y == "3" || y == "4" || y == "5" || y == "6" || y == "7" || y == "8" || y == "9")
{
newArry[i] = "0" + y; <----- Use of unassigned local variable 'newArry'
}
else
{
newArry[i] = y;
}
i++;
}
Use of unassigned local variable 'newArry'
Console.WriteLine("-------
string noZero = "1,3,5,6,7,9,10,14,16,17";
string[] leadingZeros = noZero.Split(',');
string[] newArry;
int i = 0;
foreach (string y in leadingZeros)
{
if (y == "1" || y == "2" || y == "3" || y == "4" || y == "5" || y == "6" || y == "7" || y == "8" || y == "9")
{
newArry[i] = "0" + y; <----- Use of unassigned local variable 'newArry'
}
else
{
newArry[i] = y;
}
i++;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
string[,] myArr = new string[2, 10];
int uBound = myArr.GetUpperBound(1);
ASKER
the getupperbound(1) did not work so I used .Length
Thanks anyway.
Thanks anyway.
ASKER
Just want to find out how many items in the array.
ubound(newArry,2)