tags:

views:

44

answers:

1

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?

+4  A: 

No.

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

e.g. here

Matt Howells
Tragic but true.
Charlie