Can we change the dimensions of the array like arr[4,5] dynamically ?

 Posted by Ddd on 3/7/2011 | Category: C# Interview questions | Views: 4195 | Points: 40
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 

Comments or Responses

Login to post response