Correspondence between C# and .NET Types

Primitive data types in C# have a direct correspondence with the types of the common type system (CTS) in .NET Framework. For instance, int type in C# corresponds to System.Int32 type in CTS and to Integer type in VB.NET language, while long type in C# corresponds to System.Int64 type in CTS and to Long type in VB.NET language. Due to the common types system (CTS) in .NET Framework there is compatibility between different programming languages (like for instance, C#, Managed C++, VB.NET and F#). For the same reason int, Int32 and System.Int32 types in C# are actually different aliases for one and the same data type – signed 32-bit integer.

Integer Types

You would be able to see the declaration and initialization of a variable in detail in sections “Declaring Variables” and “Initialization of Variables” below, and it would become clear from the examples.

In the code snippet above, we demonstrate the use of integer types. For small numbers we use byte type, and for very large – ulong. We use unsigned types because all used values are positive numbers.

Related Posts

© 2024 Engineering Basics - Theme by WPEnjoy · Powered by WordPress