In principle with class StreamReader
you can not perform any calculation calculation because with this you would only read the file.
But if you could dump the data from the file to a class and in this if you implement logic to calculate what you need
I would recommend evaluates
filehelpers
with this you could map the file to a class that you define in a simple way, then the data is parsed and you could use it in the calculations
You can define a class as being
[DelimitedRecord("|")]
public class Orders
{
public int OrderID;
public string CustomerID;
[FieldConverter(ConverterKind.Date, "ddMMyyyy")]
public DateTime OrderDate;
[FieldConverter(ConverterKind.Decimal, ".")] // The decimal separator is .
public decimal Freight;
}
and pause it using
var engine = new FileHelperEngine<Orders>();
var records = engine.ReadFile("Input.txt");
foreach (var record in records)
{
Console.WriteLine(record.CustomerID);
Console.WriteLine(record.OrderDate.ToString("dd/MM/yyyy"));
Console.WriteLine(record.Freight);
}
As you will see in the example, use the properties to recover the data and perform operations with these