1
Answer

how to store text file lines to arry using C#

praveen kumar

praveen kumar

7y
189
1
 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)