Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 832 Bytes

compiler-error-c2396.md

File metadata and controls

29 lines (23 loc) · 832 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Error C2396
Compiler Error C2396
11/04/2016
C2396
C2396
1b515ef6-7af4-400f-b4ed-564313ea15f6

Compiler Error C2396

'your_type::operator'type'' : CLR or WinRT user-defined conversion functionnot valid. Must either convert from or convert to: 'T^', 'T^%', 'T^&', where T = 'your_type'

A conversion function in a Windows Runtime or managed type did not have at least one parameter whose type is the same as the type containing the conversion function.

The following sample generates C2396 and shows how to fix it:

// 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);
};