3

enter image description here

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

Akash
  • 1,716
  • 2
  • 23
  • 43

4 Answers4

19

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.

Ivaylo Slavov
  • 8,839
  • 12
  • 65
  • 108
  • Not particular to C#. VB.NET has the same. – Matt Wilko Jun 05 '13 at 08:05
  • Oh, ok.. It being called Int64 threw me off – Akash Jun 05 '13 at 08:07
  • 2
    @MattWilko Not exactly, the aliases in VB are different. For instance you have `Integer`, not `int`. I have mentioned the C# specific ones. – Ivaylo Slavov Jun 05 '13 at 08:08
  • 1
    My point was that your answer inferred that C# was the only language to have aliases, but your answer as it stands now clears that up. – Matt Wilko Jun 05 '13 at 08:34
  • @MattWilko, excuse me for the delayed reply. Yes, you are correct in the context of the early version of my post and that is why I edited it, so thanks for noticing. I must admit I find it hard to write a shiny post from the first time, but gladly there is the wiki edit capability. – Ivaylo Slavov Mar 27 '14 at 10:54
  • Today I learned something – BlueWizard Jul 07 '15 at 19:47
7

Int64 is a long type.

Int32 is an int type.

Matthew Layton
  • 39,871
  • 52
  • 185
  • 313
Dariusz
  • 21,561
  • 9
  • 74
  • 114
5

.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
Mr Anderson
  • 2,200
  • 13
  • 23
Matthew Layton
  • 39,871
  • 52
  • 185
  • 313
  • 1
    "In .NET, primitive types are just short-cuts to their equivalent structures" - do you perhaps mean "In C#, some datatype keywords are exactly equivalent to certain `System` value types" ? – AakashM Jun 05 '13 at 09:02
1

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.

Community
  • 1
  • 1
CodeCamper
  • 6,609
  • 6
  • 44
  • 94