![]() |
![]() |
![]() Welcome! and rules Joel on Software |
int or Int32, long or Int64? I'm modifiying an ASP.Net app in C# in which lots of the variables are delcared as Int32s or Int64s. Lots of them are also declared as ints or longs.
Thomas David Baker
In C#, "int" is an alias for Int32, and "long" is a synonym for "Int64". If you disassemble your code with ILDASM, you'll see that the underlying types are used.
Brad Wilson (dotnetguy.techieswithcats.com)
I thought as much. The Microsoft examples seem to use int and long and they are also more familiar to me so unless someone wants to give me a good reason I think I'll go with them.
Thomas David Baker
The language primitive type keywords refer to FCL types, obviously "int" for "System.Int32". Personally I prefer the FCL type names, it more closely matches many method names in the FCL and avoids confusion. Eg. "System.Convert.ToSingle" returns a "float"!!!
Pietro
Perhaps the beginnings of a good reason there. Are the Convert static methods better/different from a cast?
Thomas David Baker
Ahhh! But with int.Parse() or long.Parse I seem to have the exact same functionality for the "friendlier" words. No?
Thomas David Baker
Something else to consider: int does indeed map to Int32 in the current versions of the framework, but might it not map to an Int64 on a 64 bit version of the framework (which MS is currently working on)?
Fred Flintstone
You mean System.Int32.Parse(...)?
Pietro
On the 64 bit issue -- Microsoft is indeed working on a 64-bit version of the .NET Framework but I'm pretty sure int will NOT map to 64 bit on that system. Reasons:
Chris Nahr
The sizes of "short", "int", and "long" in C# are set in stone. It's not ambiguous like it was in C/C++.
Brad Wilson (dotnetguy.techieswithcats.com)
|