Introduction
It's a general case that many developers are not much aware of the difference
between primitive, FCL reference and value types. It may cause of many bugs and
performance issue in the code . Here I will like to present the different behavior
of integer type.
Int16
- It is a value type.
-
Represent System.Int16 struct.
-In c#, short
is mapped to Int16.
- It is a
FCL type.
-It is
signed and takes 16 bits.
- Minimum
capacity -32768 and Maximum capacity +32767.
Int32
- It is a value type.
-
Represent System.Int32 struct.
-In c#,
int is mapped to Int32.
- It is a
FCL type.
-It is
signed and takes 32 bits.
- Minimum
capacity -2147483648 and Maximum capacity +2147483647.
Int 64
- It is a value
type.
-
Represent System.Int64 struct.
-In c#,
long is mapped to Int64.
- It is a
FCL type.
-It is
signed and takes 64 bits.
- Minimum
capacity –9,223,372,036,854,775,808and Maximum capacity +9,223,372,036,854,775,807.
Int
- It is a primitive data type defined in C#.
-It is a value type.
- Represent
Sysem.Int32 Struct.
- It is mapped to
Int32 of FCL type.
- Minimum
capacity -2147483648 and Maximum capacity +2147483647.
Important Note:
Lots of developers think that int represents
a 32-bit integer when the application is running on a 32-bit OS and it
represents a 64-bit integer when the application is running on a 64-bit OS. It
is completely wrong.