I want to create the generic method for numeric types. Here is the method:
public static T1 Sum2<T1>(this IEnumerable<T1> values)
{
return values.Sum();
}
However compiler shows me this error:
error CS1929: 'IEnumerable<T1>' does not contain a definition for 'Sum' and
the best extension method overload 'Enumerable.Sum(IEnumerable<decimal>)'
requires a receiver of type 'IEnumerable<decimal>'
Is there a way to solve this error without implementing methods for each numeric type?