C# StreamReader构造函数处的StackOverflowException
我对此代码有问题;它导致StackOverflowException。错误发生在第C# StreamReader构造函数处的StackOverflowException,c#,.net,streamreader,stack-overflow,C#,.net,Streamreader,Stack Overflow,我对此代码有问题;它导致StackOverflowException。错误发生在第streamreadfile=newstreamreader(path)行 有人知道如何解决这个问题吗?多谢各位 public string[,] parseCSV(string path) { List<string[]> parsedData = new List<string[]>(); try { using (StreamReader rea
streamreadfile=newstreamreader(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;
}
publicstring[,]parseCSV(字符串路径)
{
List parsedData=新列表();
尝试
{
使用(StreamReader readFile=新StreamReader(路径))
{
弦线;
字符串[]行;
baris=File.ReadAllLines(path).Length;
行=readFile.ReadLine().Split(',');
col=行长;
store=新字符串[baris,col];
int i=0;
int j=0;
foreach(行中的字符串kolom)
{
存储[i,j]=kolom;
j++;
}
i=1;
而((line=readFile.ReadLine())!=null)
{
行=行。拆分(',');
j=0;
foreach(行中的字符串kolom)
{
存储[i,j]=kolom;
j++;
}
i++;
parsedData.Add(行);
}
}
}
捕获(例外e)
{
//MessageBox.Show(e.Message);
}
退货店;
}
不幸的是,stackoverflow没有显示调用链
检查这家伙的呼叫者和他的呼叫者的呼叫者
这家伙不能自己抛出stackoverflow。什么
路径
会导致异常?当错误发生时,显示IDE中的调用堆栈窗口,告诉我们它是什么样子的-什么函数调用了parseCSV,大约有多少次?“path”变量中的值是多少?StreamReader是.NET framework类还是您创建了自己的SteramReader?您使用的StreamReader构造函数从未抛出StackOverflowException。你能发布一个堆栈跟踪吗?当然你得到的是OutOfMemoryException,而不是堆栈溢出?你知道你要全部读取两次,对吗?把这一切都记在记忆里。迭代器块在这里会很好。事实上,我只是使用codeproject的快速CSV阅读器——为什么要重新发明它?