Click here to Skip to main content
13,554,127 members
Rate this:
Please Sign up or sign in to vote.
See more:
Why we should Use built-in C# native data types vs .NET CTS types ( Use int Not int32, use string not String , use bool not Boolean)
Posted 19-Mar-12 1:45am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

o reason, really - it is just tidier.
int is just syntactic sugar for int32,
works the same as Boolean

It just makes the code slightly more readable, and more compatible with (for example) C and C++

If your company rules don't prevent it, you can use whichever you want - just try not to mix them!
Sergey Alexandrovich Kryukov 19-Mar-12 21:04pm
Agree, a 5.
Just a note: when we prefer int over System.Int32, we do not choose a type. The type "int" is no more then a C# alias for System.Int32. Same goes for uint, byte, sbyte, string, object, etc.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

One of the times you need to use Int32 instead of int would be if you want be double-damn sure that you get a 32-bit int in a 64-bit app (or when reading a data file), or when they redefine int to be equivalent to Int64 instead of Int32. The int used to be the same as Int16.

There are probably other examples, but that's the one that came to mind first.
Sergey Alexandrovich Kryukov 19-Mar-12 21:05pm
"They" are not really supposed to redefine them... however... who knows?
Sergey Alexandrovich Kryukov 21-Mar-12 21:09pm
I know, I know. I want to emphasize the paradigm shift in .NET: C approach was focus on platform-dependent types, .NET - on platform-independent. You know that for two 64-bit targets int is 32-bit, exactly as in x86. That is the difference. A 128-bit integers will be added without replacing any other existing types.

A point?
In VS 1.51, an int was 16-bits. In a later version (I don't know which version this happened), it was made equivalent to an Int32 (but you could still use int as your type definition). At some point, int will be an Int64, probably when/if we ever see 128-bit operating systems.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180515.1 | Last Updated 19 Mar 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100