C# FAQ: Are standard types the same in Cplusplus and CSharp

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:FAQs
edit

Are standard types the same in C++ and C#?

C# features several basic types which are similar to those in C++ including array, char, class, double, float, int, long, string, and struct.

However, although the names may be familiar, the devil—or god, if you prefer —is in the details. For instance, whereas the size of a C++ long depends on the platform—usually, 32 bits on a 32-bit platform and 64 bits on a 64-bit platform—, a C# long is fixed at 64 bits. Further, although classes and structs are very similar in C++, they are different in C#. One final example, .NET char and string are 16 bit (Unicode/UTF-16) rather than the 8-bit C++ types.

See also


Personal tools