[Solved] Not able to get sum of array in C#
Your error is from these lines: Console.WriteLine(rea.ReadLine()); ad.Add(Int32.Parse(rea.ReadLine())); What’s happening is you are getting the count of the number of lines in the file. Say your file has 10 lines. When the loop reaches the last line and you call ReadLine method in Console.WriteLine(rea.ReadLine());, it returns the last line. But then you call Readline method … Read more