I have a 2D char array
.
I want loop through and add each char
+ index
in consecutive order to a new 1D list
.
So the new 1D list will display as:
G0
V1
H2
F3
I4
E5
V6
A7
U8
G9
N10
L11
...
C#
char[,] array = new char[6,4] {
{ 'G', 'V', 'H', 'F' },
{ 'I', 'E', 'V', 'A' },
{ 'U', 'G', 'N', 'L' },
{ 'G', 'X', 'F', 'W' },
{ 'E', 'N', 'L', 'H' },
{ 'A', 'H', 'V', 'B' }
};
List<string> matrixCharacters = new List<string>();
for (int m = 0; m < 24; m++) // marix positions 24
{
for (int r = 0; r < 6; r++) // matrix rows 6
{
for (int c = 0; c < 4; c++) // matrix columns 4
{
matrixCharacters.Add(array[r,c].ToString() + r.ToString());
}
}
}
But I'm having trouble making a loop that can do it.
This displays:
http://rextester.com/RPRXM23687
G0
V0
H0
F0
I1
E1
V1
A1
U2
G2
N2
L2
...
Method 2 displays:
http://rextester.com/TYLJE96460
GVHF0
IEVA1
UGNL2
GXFW3
ENLH4
AHVB5