Array Declaration. Simple Question. Thanks.

S

Shapper

Hello,

I have this array:

Dim myArray() As String = {"A", "B", "C", "D", "E", "F"}

However I need to declare the array and assign the values in different
places of my code so I have:

Dim myArray() As String
....
myArray() = {"A", "B", "C", "D", "E", "F"}

The second line not working.

Can someone tell me why?

Thanks,
Miguel
 
I

Islam Elkhayat

You have to give your array a size or initial values then assign values
using index...
in [C#]
string[] myArray = new string[size];
or
string[] myArray = {"A","B","C"};

then use the index to assign values..
myArray[0] = "A";
myArray[1] = "B";
........................................................
 
K

Kevin Spencer

Yes, I can. And I did. Twice now. In detail. See your previous post.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 
K

Kevin Spencer

No problemo, Miguel. We all need a second pair of eyes now and then!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top