distributed-computing/tasks/moiseev-vv/lab_2/worker-2/Program.cs

11 lines
390 B
C#
Raw Permalink Normal View History

string[] numbers = File.ReadAllLines("/var/data/data.txt");
Console.WriteLine("Чисел для обработки: " + numbers.Length);
long sum = 0;
foreach (var numberStr in numbers)
{
if (!int.TryParse(numberStr, out int number))
throw new ArgumentException("Wrong number " + numberStr);
sum += number;
}
File.WriteAllText("/var/result/result.txt", sum.ToString());