long
is a keyword both in C# and C++. They simply don't mean the same thing. The C++/CLI designers went for the C++ interpretation since C++ was the target interop language.
Not exactly the only unintuitive mapping:
- C# byte => C++/CLI unsigned char
- C# sbyte => C++/CLI char
- C# char => C++/CLI wchar_t
- C# ushort => C++/CLI unsigned short
- C# uint => C++/CLI unsigned int
- C# long => C++/CLI long long
- C# ulong => C++/CLI unsigned long long
- C# string => no equivalent, use System::String^
- C# decimal => no equivalent, use System::Decimal
- C# object => no equivalent, use System::Object^
- C# enum => C++/CLI public enum class
- C# struct => C++/CLI value struct
- C# class => C++/CLI ref class
- C# interface => C++/CLI interface class
- C# nullable types with ? => no equivalent, use Nullable<>
Beware the required public
keyword for an enum, a necessary evil since C++11 adopted the enum class
syntax.
Only the void, bool, short, int, float and double keywords match.