[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

unassigned error

Posted on 2006-07-10
4
Medium Priority
?
361 Views
Last Modified: 2012-05-05
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++;
            }
0
Comment
Question by:Isaac
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 400 total points
ID: 17076634
You have only declared newArry as an array, you haven't actually created an array.

You either need to size the array initially, or use a more flexible container (perhaps an ArrayList).

    string[] newArry = new string[15];          // Size will be dependent on how many items it needs to hold
0
 
LVL 5

Author Comment

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

ubound(newArry,2)
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17076807

        string[,] myArr = new string[2, 10];
        int uBound = myArr.GetUpperBound(1);
0
 
LVL 5

Author Comment

by:Isaac
ID: 17076883
the getupperbound(1) did not work so I used .Length

Thanks anyway.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question