Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

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++;
            }
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Isaac

ASKER

how can I convert this from vbscript to c#:
Just want to find out how many items in the array.

ubound(newArry,2)

        string[,] myArr = new string[2, 10];
        int uBound = myArr.GetUpperBound(1);
Avatar of Isaac

ASKER

the getupperbound(1) did not work so I used .Length

Thanks anyway.