So I have a generic number check that I am trying to implement:
public static bool isNumberValid(string Number)
{
}
And I want to
You could try something like this:
FileStream fsIn = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
using (StreamReader sr = new StreamReader(fsIn))
{
line = sr.ReadLine();
while (!String.IsNullOrEmpty(line)
{
line = sr.ReadLine();
//call isNumberValid on each line, store results to list
}
}
Then print the list using FileStream
.
As other people have mentioned, your isNumberValid
method could make use of the Int32.TryParse
method, but since you said your text file only contains numbers this may not be necessary. If you're just trying to match the number exactly, you can use number == line
.