This documentation is archived and is not being maintained.

Compiler Error C2396

'your_type::operator'op'' : CLR UDC operator not valid. Must either convert from or convert to: 'T^', 'T^%', 'T^&', where T = 'your_type'

An operator in a managed type did not have at least one parameter whose type is the same as the type containing the operator.

The following sample generates C2396:

// C2396.cpp
// compile with: /clr /c

ref struct Y {
   static operator int(char c);   // C2396

   // OK
   static operator int(Y^ hY);
   // or
   static operator Y^(char c);
};
Show: