1 October 2013

Difference between int, Int16, Int32 and Int64 in c#


 FCL (framework class library), reference, and value types. This cause bugs and performance issues into the code. In this article, I would like to expose the different behavior of integer type.

int

1.     It is a primitive data type defined in C#.
2.     It is mapped to Int32 of FCL type.
3.     It is a value type and represent System.Int32 struct.
4.     It is signed and takes 32 bits.
5.     It has minimum -2147483648 and maximum +2147483647 capacity.

Int16

1.     It is a FCL type.
2.     In C#, short is mapped to Int16.
3.     It is a value type and represent System.Int16 struct.
4.     It is signed and takes 16 bits.
5.     It has minimum -32768 and maximum +32767 capacity.

Int32

1.     It is a FCL type.
2.     In C#, int is mapped to Int32.
3.     It is a value type and represent System.Int32 struct.
4.     It is signed and takes 32 bits.
5.     It has minimum -2147483648 and maximum +2147483647 capacity.

Int64

1.     It is a FCL type.
2.     In C#, long is mapped to Int64.
3.     It is a value type and represent System.Int64 struct.
4.     It is signed and takes 64 bits.
5.     It has minimum –9,223,372,036,854,775,808 and maximum 9,223,372,036,854,775,807 capacity.


No comments:

Post a Comment