提问人:NeedthisPLEASE 提问时间:4/14/2023 最后编辑:NeedthisPLEASE 更新时间:4/14/2023 访问量:17
流阅读器。当文本文件为字符串时,读取错误计为 int
StreamReader .Read error counted as int when the text file is string
问:
static void Main(string[] args)
{
StreamReader blobread = new StreamReader("input.txt");
int height = int.Parse(blobread.ReadLine());
int width = int.Parse(blobread.ReadLine());
char[,] globs = new char[width, height];
for (int i = 0; i<width; i++)
{
for (int j = 0; j < height; j++)
{
globs[i, j] = blobread.Read();
}
}
blobread.Close();
Console.ReadKey();
}
输入 .txt 就是这样
我正在尝试让流阅读器读取 .'s 和 # 一个接一个,我假设.Read 是为此目的的,但当我尝试使用它时,它根本无法运行。
我试过解析.阅读,我尝试使用.ReadLine,但它读取整行,我只想让 2d 数组的每个插槽都填充一个 .# 或 A,而不是整个字符串。
答: 暂无答案
评论