Shouldn't it be an integer type instead?
This way, some functions which are using int fail to accept this as an argument, since it returns a long but they expect an int
Shouldn't it be an integer type instead?
This way, some functions which are using int fail to accept this as an argument, since it returns a long but they expect an int
In .NET there are common built-in type aliases for all primitive and some standardized types. Each alias corresponds to an actual .NET type, and both the alias and the type name can be used interchangeably.
Here is a list some of the aliases in C#. Other .NET languages, might use different aliases for the same types (like is the case with VB.NET)
byte -> System.Byte short -> System.Int16 int -> System.Int32 long -> System.Int64 string -> System.String ...
As you can see, System.Int64
represents a 64-bit integer a.k.a. a long
.
Int64
is a long
type.
Int32
is an int
type.
.NET uses type aliases for certain types. This means that the type alias is the exact equivalent of it's relative value type. As you can see from the list below, the type alias for System.Int64 is "long". Here is the full list of type aliases in .NET.
//Alias | Relative Data Type
byte | System.Byte
sbyte | System.SByte
short | System.Int16
ushort | System.UInt16
int | System.Int32
uint | System.UInt32
long | System.Int64
ulong | System.UInt64
float | System.Single
double | System.Double
decimal | System.Decimal
string | System.String
bool | System.Boolean
object | System.Object
Long == Int64 >>Output: True
Int == Int32 >>Output: True
Int64 == Int32 >>Output: False
You can only convert a Long/Int64 to an Int/Int32 if it is small enough but you can always convert an Int to a Long. Int64/Long supports numbers larger and smaller than the standard Int.