Answer: Yes, we can change both the dimensions of this array dynamically.
Code:
int[,] arr = new int[4, 5];
Console.WriteLine(arr.GetLength(0) + "---" + arr.GetLength(1));
int b = 6;
arr = new int[b, b];
Console.WriteLine(arr.GetLength(0) + "---" + arr.GetLength(1));
When you run the program, the Getlengthmethod will show different number of dimensions.
Asked In: Many Interviews |
Alert Moderator