I am trying to implement a generic operator like so:
class Foo
{
public static T operator +(T a, T b)
{
// Do something with a and b t
https://jonskeet.uk/csharp/miscutil/usage/genericoperators.html
static T Add(T a, T b) {
//TODO: re-use delegate!
// declare the parameters
ParameterExpression paramA = Expression.Parameter(typeof(T), "a"),
paramB = Expression.Parameter(typeof(T), "b");
// add the parameters together
BinaryExpression body = Expression.Add(paramA, paramB);
// compile it
Func add = Expression.Lambda>(body, paramA, paramB).Compile();
// call it
return add(a,b);
}