Your browser does not support JavaScript! Please enable script of your browser.
 
Coding is Rhyme
Handy Tricks For Beginners & Professionals
C# 5.0, 4.0 - Tutorial, Article, Archive, Pdf, Handy Tricks, Code Snippets, Training, Reference Manual, .Net Framework, CLR, CTS, MSIL, IL, Class, Structure, Constructor, Property, Indexer, Inheritance, Interface, Delegates, Attributes

Difference between int, Int16, Int32 and Int64

Posted By : Shailendra Chauhan, 29 Dec 2012
Updated On : 05 Jan 2013
Keywords : C# int Int16 Int32 Int64,int vs Int16 vs Int32 vs Int64

In the learning phase developer are not much aware of the difference between primitive, 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.

Note

  1. A number 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. This is absolutely wrong.

  2. In C# int is a primitive data type and it always mapped to System.Int32 whether the OS is 32-bit or 64-bit.

What do you think?

I hope you will enjoy the tips while programming with C#. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

About the Author
Shailendra Chauhan works as Sr. Software Engineer at reputed MNC and has more than 5 years of hand over Microsoft .NET technologies. He is a .NET Consultant and is the founder & chief editor of www.dotnet-tricks.com and www.dotnetinterviewtricks.com blogs. He is an author of books ASP.NET MVC Interview Questions and Answers & LINQ Interview Questions and Answers.
He loves to work with web applications and mobile apps using Microsoft technology including ASP.NET, MVC, C#, SQL Server, WCF, Web API, Entity Framework,Cloud Computing, Windows Azure, jQuery, jQuery Mobile, Knockout.js, Angular.js and many more web technologies. More...
 
 
Recommended Articles!
 
 
Search Articles
 
 
Subscribe & follow Us
 
 
Protected by Copyscape Web Plagiarism Check
 
Free ASP.NET MVC Interview Book
Learn In Hindi
Browse By Category
 
Recent Articles
 
Popular Articles
 
Like us on Facebook
 
Featured AD
Join our Training programs in Delhi/Noida on ASP.NET MVC, WCF, EF, jQuery - call us    +91-9871749695