Whit
Explore posts from serversHow to perform LINQ Average against collection of TValue constrained as INumber<TValue>
I would like to perform an average against a collection of TValue wherein I know TValue is a number because I've constrained it to INumber<TValue>. However, when trying to use it in the LINQ expression, it doesn't appear to know how to handle the arbitrary number type:
CS0029: Cannot implicitly convert type 'TValue' to 'long?'Any guesses as to how I can handle this generically without writing a separate overload for every numeric type? Thank you!
22 replies