how to store text file lines to arry using C#

Jul 22 2017 2:09 AM
 showing error
 
 
 
 
using (StreamReader r = new StreamReader(filename)
{
string s = string.Empty;
int i = 0;
while ((i = r.Read()) != -1)
{
Char c = Convert.ToChar(i);
if (Char.IsDigit(c) || Char.IsLetter(c))
{
s = s + c;
}
else
{
if (s.Trim() != string.Empty)
Console.WriteLine(s);
s = string.Empty;
}
}

Answers (1)