public List<string[]> parseCSV(string path)
{
List<string[]> parsedData = new List<string[]>();
try
{
using (StreamReader readFile = new StreamReader(path))
{
string line;
string[] row;
while ((line = readFile.ReadLine()) != null)
{
row = line.Split(',');
parsedData.Add(row);
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
return parsedData;
}
我想使用此代碼來解析CSV,並返回一個填充數組的列表。我的問題是如何遍歷列表中的數組,如果他們是未知的大小?迭代通過C#中的數組填充的列表中的代碼
例如:
for (int a=0; a<=CSVList(firstindex).Length;a++)
for (int a=0; a<=CSVList(secondindex).Length;a++)
像這樣的閱讀CSVList在它的第一個索引,然後第一個數組元素......我想我真的很憋屈的語法。
謝謝
對,我的問題是更多的C#的語法和迭代通過列表的數組 – Joel 2011-02-25 20:42:20