I know they are the same variable type, but is there an accepted standard 'style' for whether to use long
or Int64
?
I would like to use the most common one.
In C#, long is mapped to Int64. It is a value type and represent System. Int64 struct. It is signed and takes 64 bits.
Int64 is an immutable value type that represents signed integers with values that range from negative 9,223,372,036,854,775,808 (which is represented by the Int64. MinValue constant) through positive 9,223,372,036,854,775,807 (which is represented by the Int64. MaxValue constant.
An int (aka System. Int32 within the runtime) is always a signed 32 bit integer on any platform, a long (aka System.
All documentation from Microsoft and 99.999% (or so) of the code you'll find online will use long
. See for instance the numeric datatype definition in the C# reference: http://msdn.microsoft.com/en-us/library/exx3b86w.aspx
In the end, this is the same issue with using string
or String
. In general, lowercase names are used for value datatypes like numbers or characters, and uppercase names are used for classes. In C# Int64
is the complex datatype (a structure with fields, properties and methods, see the doc here) for the long
value datatype (see the doc here). In general, people don't use the class Int64
for other than invoking methods from that class, such as Int64.Parse
. So you will usually find something like this:
long variable = 9.5f; string text = "8.4"; long anotherVariable = Int64.Parse(text);
You will get so many different opinions for a question like this since they're the exact same thing. So it's up to you. Microsoft pretty much always uses long
, int
and short
in their documentation and examples. It's simply an Alias in VB.NET and C#. So I guess it's better usage to use them that way.
long
instead of Int64
int
instead of Int32
short
instead of Int16
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With