21 lines
468 B
C#
21 lines
468 B
C#
var collection = File.ReadLines("/var/data/data.txt");
|
|
|
|
if (!collection.Any())
|
|
{
|
|
throw new ArgumentException("Incorrect file");
|
|
}
|
|
|
|
if (!int.TryParse(collection.First(), out int firstNumber))
|
|
{
|
|
throw new ArgumentException("Wrong number");
|
|
}
|
|
|
|
if (!int.TryParse(collection.Last(), out int lastNumber))
|
|
{
|
|
throw new ArgumentException("Wrong number");
|
|
}
|
|
|
|
var result = lastNumber * firstNumber;
|
|
|
|
File.WriteAllText("/var/result/result.txt", result.ToString());
|