11 lines
390 B
C#
11 lines
390 B
C#
|
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());
|