As C# operators e.g. +, +=, == are overridable. It lets me think they are sort of methods, thus wonder if there is a way to call them using reflection, on Int32 for instance.
What about this, it's simple, small and works :)
public T Add<T>(object x, object y) { return (T)Convert.ChangeType((dynamic)x + (dynamic)y, typeof(T)); }
1.4m articles
1.4m replys
5 comments
57.0k users