M
MP
Hi
I have twp questions about arrays in c#
1) I have made following initialization:
// Create and initialize the names array
string[,] mediaClasses =
{
{"TYPE1","SubType1", "1", "10", "100", "2*2", "1000", "2", "223"},
{"TYPE2","SubType2", "1", "10", "500", "2*4", "1000", "4", "555"},
{"TYPE3","SubType3","0","0","0","0","0","0","0"},
{"TYPE4","SubType4 ","0","0","0","0","0","0","0"}
};
It is all string. I would like to know is possible to made some elements as
strings some as integer?
2) How I can add new line into array runtime?
I have tried following:
int NewRow;
int numberOfRows = mediaClasses.GetLength(0);
NewRow = numberOfRows;
mediaClasses.SetValue(txbType.Text, NewRow,0);
mediaClasses.SetValue(txbSubType.Text, NewRow,1);
mediaClasses.SetValue(txbProductID.Text, NewRow,2);
but did not works![Frown :( :(](/styles/default/custom/smilies/frown.gif)
Like I told you I am new in c# and I will appreciate some short example if
is possible.
Thanks in advance.
I have twp questions about arrays in c#
1) I have made following initialization:
// Create and initialize the names array
string[,] mediaClasses =
{
{"TYPE1","SubType1", "1", "10", "100", "2*2", "1000", "2", "223"},
{"TYPE2","SubType2", "1", "10", "500", "2*4", "1000", "4", "555"},
{"TYPE3","SubType3","0","0","0","0","0","0","0"},
{"TYPE4","SubType4 ","0","0","0","0","0","0","0"}
};
It is all string. I would like to know is possible to made some elements as
strings some as integer?
2) How I can add new line into array runtime?
I have tried following:
int NewRow;
int numberOfRows = mediaClasses.GetLength(0);
NewRow = numberOfRows;
mediaClasses.SetValue(txbType.Text, NewRow,0);
mediaClasses.SetValue(txbSubType.Text, NewRow,1);
mediaClasses.SetValue(txbProductID.Text, NewRow,2);
but did not works
![Frown :( :(](/styles/default/custom/smilies/frown.gif)
Like I told you I am new in c# and I will appreciate some short example if
is possible.
Thanks in advance.