2D array isn't created as expected in C#
In a simple C# console application I have the following:
class Program
public static void Main()
{
string s = Console.ReadLine(); //User enters the string: "integer,
space, integer". Eg., "3 3"
string[,] myArray = new string[s[0], s[0]];
..
..
..
}
Upon debugging, the value of myArray will show string[53, 53], but I'm
expecting string[3, 3]. However, if I Console.WriteLine(s[0]), it prints
"3".
I've tried
string[,] myArray = new string[(int)s[0], (int)s[0]];
with the same result.
Where are the 53's coming from?
No comments:
Post a Comment