I have an dimensional array which is hardcoded which i would like to make an for loop for so randomized characters get inserted.
And then show it in the console as 3 by 3 with an foreach (that is what i tried):
a b c
d b a
a b d
So i can count them since i need to make a pointing system as they have specific points. (this i can manage on my own) But i was stuck with the dimensional array. It worked with a single dimension array but i need a 3 by 3 pointing game system.
Random random = new Random();
String chars = "ABCD";
// the array i want to make a for loop for
string[,] main = new string[3, 3];
// the example array how it should look after the for loop inserted data.
string[,] main_example = new string[3, 3] { { "c", "b", "a" }, { "d", "a", "b" }, { "a", "d", "a" }
};
// inserts a or b or c or d.
for (int i = 0; i < cards9.Length; i++) {
main[i, i] += chars[random.Next(chars.Length)];
}
// the foreach to display the data in the console
foreach (string i in main) {
System.Console.Write("{0} ", i);
}