2D array

G

Guest

How do I declare and ADD to a 2D array ?

I declared it as:
string[,] stdAnswer = new String[2,50];

Usually in a 1D array, adding would be done by:
ArrayList values = new ArrayList();
values.Add ("IN");

TIA.
 
G

Grant Merwitz

if your data looks like this

column1 column2
a 1
b 2
c 3

then

strAnswer[0,0] = "a";
strAnswer[0,1] = "1";
strAnswer[1,0] = "b";
strAnswer[1,1] = "2";
strAnswer[2,0] = "b";
strAnswer[2,1] = "3";

so, [value,value] means [rowindex, columnindex]
 

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
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top