StreamReader 构造函数中的 StackOverflowException
我对这段代码有疑问;它导致了 StackOverflowException。错误发生在 StreamReader readFile = new StreamReader(path)
行。
有人知道如何解决这个问题吗?谢谢。
public string[,] parseCSV(string path)
{
List<string[]> parsedData = new List<string[]>();
try
{
using (StreamReader readFile = new StreamReader(path))
{
string line;
string[] row;
baris = File.ReadAllLines(path).Length;
row = readFile.ReadLine().Split(',');
col = row.Length;
store = new string[baris, col];
int i = 0;
int j = 0;
foreach (string kolom in row)
{
store[i, j] = kolom;
j++;
}
i=1;
while ((line = readFile.ReadLine()) != null)
{
row = line.Split(',');
j = 0;
foreach (string kolom in row)
{
store[i, j] = kolom;
j++;
}
i++;
parsedData.Add(row);
}
}
}
catch (Exception e)
{
//MessageBox.Show(e.Message);
}
return store;
}
I have a problem with this code; it caused StackOverflowException. The error occurred in line StreamReader readFile = new StreamReader(path)
.
Anyone have an idea how to solve this problem? Thank you.
public string[,] parseCSV(string path)
{
List<string[]> parsedData = new List<string[]>();
try
{
using (StreamReader readFile = new StreamReader(path))
{
string line;
string[] row;
baris = File.ReadAllLines(path).Length;
row = readFile.ReadLine().Split(',');
col = row.Length;
store = new string[baris, col];
int i = 0;
int j = 0;
foreach (string kolom in row)
{
store[i, j] = kolom;
j++;
}
i=1;
while ((line = readFile.ReadLine()) != null)
{
row = line.Split(',');
j = 0;
foreach (string kolom in row)
{
store[i, j] = kolom;
j++;
}
i++;
parsedData.Add(row);
}
}
}
catch (Exception e)
{
//MessageBox.Show(e.Message);
}
return store;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是 stackoverflow 不显示调用链。
一直检查这个人的来电者以及他的来电者的来电者。
这家伙不能自己抛出stackoverflow。
Unfortunately stackoverflow doesn't present the call chain.
Check this guy's callers and callers of his callers all the way up.
This guy can't throw stackoverflow by himself.