string WRitePath = @"";
string line;
int Sum = 0;
StreamReader sr = new StreamReader(WRitePath, System.Text.Encoding.Default);
while ((line = sr.ReadLine()) != null)
{
decimal number = Convert.ToDecimal(line);
decimal An = number + Sum;
Console.WriteLine(An);
}
sr.Close();
Console.WriteLine(File.ReadAllLines(@"D:\\nums.txt").Select(s => Convert.ToDouble(s)).Sum());
string WRitePath = @"";
string line;
decimal Sum = 0;
StreamReader sr = new StreamReader(WRitePath, System.Text.Encoding.Default);
while ((line = sr.ReadLine()) != null)
{
decimal number = Convert.ToDecimal(line);
Sum+= number;
}
sr.Close();
Console.WriteLine(Sum);
Console.ReadKey();