am I doing the addition wrong? The result does not give the total number
public float GetGrandTotal(UtilizationDto issues)
{
var grandTotal = 0.0f;
grandTotal += (float)issues.PercentCalculation;
return grandTotal;
}
>Solution :
Just declare your grandTotal variable in global and on each call it will not reset 0
public float grandTotal {get; set;} = 0.0f;
public float GetGrandTotal(UtilizationDto issues)
{
grandTotal += (float)issues.PercentCalculation;
return grandTotal;
}
public float Main(){
GetGrandTotal(new UtilizationDto { PercentCalculation= 1.0f});
GetGrandTotal(new UtilizationDto { PercentCalculation= 2.0f});
return grandTotal;
}