using System;
using System.Collections;
class MDArrayDemo
{
public static void Main()
{
string [,] array1 = new string[2, 2];
array1[0,0] = "Subhadra";
array1[0,1] = "Leon";
array1[0,2] = "Maria";
array1[1,0] = "Shawn";
array1[1,1] = "Chantel";
array1[1,2] = "Cheryl";
array1[2,0] = "Nithya";
array1[2,1] = "Suresh";
array1[2,2] = "Kittu";
Console.WriteLine("My Family {0}\n, {1}\n, {2}",array1 [0,0],array1 [0,1],array1 [0,2]);
Console.WriteLine("Pseudos {0}\n, {1}\n, {2}",array1 [1,0],array1 [1,1],array1 [1,2]);
Console.WriteLine("Vile {0}\n, {1}\n, {2}",array1 [2,0],array1 [2,1],array1 [2,2]);
}
}
此代码抛出一个Array out of bounds-Exception
.
我哪里出错了,有没有更好的方法来实现它?