0

I want to make a class that contains basic arithmetical operations with one generic type (it have to be struct) but I can't limit the generic type with something that make sure compiler that this type will be able to do arithmetical operations. Simple example:
T Sum<T>(T x, T y) { return x + y; }
Error: Operator "+" can't be used on T operands. Using limitation lead to the same problem:
T Sum<T>(T x, T y) where T: struct { return x + y; }
What name of the class/interface that contains signatures for basic arithmetical operations that I can use in where construction to make sure compiler that generic type will have ability to work with arithmetical operations? I coudln't even find it in .NET documentaion.

CIRCULARKA
  • 11
  • 2

0 Answers0