With C# 8 default interface methods you can achieve something similar, but it might not solve your exact use case:
You can define an interface with a default implementation of an operator:
public interface IFoo
{
double Value { get; }
public static IFoo operator +(IFoo a, IFoo b)
{
return new Foo(a.Value + b.Value);
}
}
public class Foo : IFoo
{
public double Value { get; }
public Foo(double value)
{
Value = value;
}
}
And consume it in a generic method/class like this:
public static class Program
{
public static void Main()
{
var f1 = new Foo(1);
var f2 = new Foo(2);
var sum = Add(f1, f2);
Console.WriteLine(sum.Value);
}
public static IFoo Add<T>(T a, T b) where T : IFoo
{
return a + b;
}
}