我似乎無法讓我的csv文件將數據存儲到2D數組中。從windows窗體應用程序的CSV文件中讀取數據並將其存儲到2D數組中
這就是我的代碼看起來像至今:
try
{
string nrValues;
fs = new FileStream(path, FileMode.Open, FileAccess.Read); // open for reading
// the file has opened; can read it now
sr = new StreamReader(fs);
while (!sr.EndOfStream)
{
line = sr.ReadLine();
parts = line.Split(',');
for (int i = 0; i < sizes.Length; i++)
{
textiles[nrValues, i] = parts[i];
}
nrValues++;
}
這是我的CSV文件看起來像:
什麼是'大小'? – Jaco
您還將'nrValues'定義爲一個字符串而不是int,這會導致編譯錯誤,至少對於nrValues ++來說。 – Jaco