共用方式為


編譯器錯誤 C2396

'your_type::operator'type'' : CLR 或 WinRT 使用者定義轉換函式無效。 必須從 轉換或轉換成:'T^'、'T^%'、'T^&',其中 T = 'your_type'

Windows 執行階段或受管理的類型中的轉換函式沒有至少一個參數,其類型與包含轉換函式的類型相同。

下列範例會產生 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);
};