c# what is the shortest way to verify integer values
i am reading values from the file and checking the values my code is
while (sr.EndOfStream != null)
{
a= sr.EndOfStream ? "" : sr.ReadLine();
if (Convert.ToInt32(a) < 1)
{
Console.WriteLine(a+ " is not a right value");
flag = true;
break;
}
b= sr.EndOfStream ? "" : sr.ReadLine();
if (Convert.ToInt32(b) < 1)
{
Console.WriteLine(b+ " is not a right value");
flag = true;
break;
}
....
Is there any other way to make my code look good
No comments:
Post a Comment