0

Is there anyway to define type parameter T as the ones that define operator overloading? Take for example, I need to create a generic Add function with the parameter T. Obviously, the T must defined the + operator, i.e.,

 public static T operator +(T c1,T c2)
 {
// plus operation
 }

Is there anyway to constraint T so that it is restricted to the types that overload the operators?

Graviton
  • 81,782
  • 146
  • 424
  • 602

1 Answers1

4

No.

Keeping it short as this question has been duplicated many times.

e.g. here

Community
  • 1
  • 1
Matt Howells
  • 40,310
  • 20
  • 83
  • 102