0

当我使用 File.WriteAllLines 它只接受一维数组。现在,我只有:

for (int x = 0; x < BookList_Array.Length; x++)
{
    writer.WriteLine(BookList_Array);
}

BookList_Array 是二维数组。当我输入一些内容并将其保存到数组中时,当我将其写入文本文件时,文本文件只显示以下内容:

System.String[,]
System.String[,]
System.String[,]

显示 20 次(这是我的数组索引的上限)

4

1 回答 1

1

尝试

 int[,] BookList_Array = new BookList_Array[2,2];
for (int x = 0; x < BookList_Array.GetLength(0); x++)
    {
        for (int j = 0; j < BookList_Array.GetLength(1); j++)
            {
                  writer.WriteLine(BookList_Array[x,j].ToString());
            }

    }
于 2013-06-14T09:20:10.300 回答