in C# console app, how do you put the first digit of split string into two dimensional array?
string[,] table3x3 = new string[3, 3];
string myString = "11A23A4A5A87A5";
string[] splitA = myString.Split(new char[] { 'A' });
Let’s say I have 2-dimensional array of 3×3 and a string with numbers and a vowel. I split them so that I can put them inside the 2Darray. What kind of loop should I include so that the output would be
Console.WriteLine(table3x3[0, 0]); //output: blank
Console.WriteLine(table3x3[0, 1]); //output: blank
Console.WriteLine(table3x3[0, 2]); //output: 2
Console.WriteLine(table3x3[1, 0]); //output: blank
Console.WriteLine(table3x3[1, 1]); //output: 4
Console.WriteLine(table3x3[1, 2]); //output: 5
Console.WriteLine(table3x3[2, 0]); //output: 8
Console.WriteLine(table3x3[2, 1]); //output: blank
Console.WriteLine(table3x3[2, 2]); //output: 5
Visually, the output would be like:
[ ][ ][2]
[ ][4][5]
[8][ ][5]
There are 9 numbers and 5 vowels inside the string. It returns the first digit of split string into specific 2Darray according to their sequences.
This should do it:
Demo: http://ideone.com/X0LdF
Or alternatively, adding to your original starting point:
Demo: http://ideone.com/7sKuR