I have a problem with this code snippet:
public decimal consumo_promedio(int serial_mic)
{
foreach (var item in objconnection.consumo_lco(serial_mic))
{
a = a + item.consumo_lco;
counter++;
}
decimal promedio = (a / counter);
decimal aux = Math.Round(promedio,MidpointRounding.ToEven);
return aux;
}
Basically what I want is for the average variable to perform a basic operation, which is to divide 29/6 for example ... the variables a and counter are integers but it is assumed that depending on the cases the average variable may or may not obtain decimal values .... the problem is that the average variable only stores the entire part of the result and not the decimal part ...