Instead of using a
while
for your inner loop, use a
for
:
while (!sr.EndOfStream)
{
line = sr.ReadLine();
mass_t = line.Split(';');
for (int i = 0; j < mass_t.Length; j++)
{
temp = mass_t[j];
data[i, j] = temp;
}
i++;
}
Or better, use File.ReadAllLines to read them all into an array of strings, and use
foreach
on that array.
Even better than that though would be to use
A Fast CSV Reader[
^] which will handle quoted strings as well. It can be configured to use ";" instead of "," as the separator.