Should I use int or Int32

前端 未结 30 2592
野性不改
野性不改 2020-11-22 11:52

In C#, int and Int32 are the same thing, but I\'ve read a number of times that int is preferred over Int32 with no reason

30条回答
  •  无人共我
    2020-11-22 12:26

    int is the C# language's shortcut for System.Int32

    Whilst this does mean that Microsoft could change this mapping, a post on FogCreek's discussions stated [source]

    "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:

    1. The C# ECMA standard specifically says that int is 32 bit and long is 64 bit.

    2. Microsoft introduced additional properties & methods in Framework version 1.1 that return long values instead of int values, such as Array.GetLongLength in addition to Array.GetLength.

    So I think it's safe to say that all built-in C# types will keep their current mapping."

提交回复
热议问题