I am trying to do Sum operation on a custom defined type class Percentage
public class Percentage
{
private readonly decimal pctDecimal; //This has to be private
public Percentage(decimal decimal_value)
{
this.pctDecimal = decimal_value;
}
}
I am using an Extension method to do the sum
public static class SumExtensions
{
public static Percentage Sum(this IEnumerable<Percentage> source)
{
return source.Aggregate((x, y) =>
{
(x + y); //I am getting Error here that "Operator '+' cannot be applied to operand of Type Percentage and Percentage."
});
}
}
Any Solution here?