Advertisement

07.05.2008 at 05:36PM PDT, ID: 23541155
[x]
Attachment Details

Creating Unknown Variable Names

Asked by tr57285 in C# Programming Language

Tags: C#

I am trying to create unknown variable names (because the amount of variables I need to create will only be known during runtime). So I need to create then during runtime. I am using the below two lines of code to do so, but I am at a loss as to what I am missing:

                        String strRow = "row" + newCounter.ToString();
                        String[] strRow = new String[4];

The first line will create a String names e.g. "row0". I then want to use that name in the second line to create the new String Array unknown variable.

I am receiving the below two errors (which are obvious to me why, but I am at a loss as to how I can fix them:

Error      1      A local variable named 'strRow' is already defined in this scope
Error      2      Cannot implicitly convert type 'string[]' to 'string'

Any thoughts?

Thank youStart Free Trial
[+][-]07.05.2008 at 06:00PM PDT, ID: 21938942

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 07:08PM PDT, ID: 21939072

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 07:32PM PDT, ID: 21939110

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 07:44PM PDT, ID: 21939127

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 07:51PM PDT, ID: 21939133

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C# Programming Language
Tags: C#
Sign Up Now!
Solution Provided By: naspinski
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628