Should I use int or Int32

前端 未结 30 2460
野性不改
野性不改 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 a C# keyword and is unambiguous.

    Most of the time it doesn't matter but two things that go against Int32:

    • You need to have a "using System;" statement. using "int" requires no using statement.
    • It is possible to define your own class called Int32 (which would be silly and confusing). int always means int.

提交回复
热议问题