I have a 10x10 matrix that I am filling with random chars. My problem is that I can't figure out how to insert a string "HOUSE"
into the first row of the table.
Random rchar = new Random();
string word = "HOUSE";
char[] wordChars = word.ToCharArray();
char[,] arr = new char[10, 10];
//Size of Rows and Cols
var rowLength = arr.GetLength(0);
var colLength = arr.GetLength(1);
for (int x = 0; x < rowLength; x++)
{
for (int y = 0; y < colLength; y++)
{
arr[0, y] = wordChars[1];
arr[x, y] = (char)(rchar.Next(65, 91));
Console.Write(arr[x, y] + " ");
}
Console.WriteLine();
}
I was trying to place a new value with the SetValue
property but it doesn't work for me because I have a two-dimensional array.