Should I use int or Int32

前端 未结 30 2195
野性不改
野性不改 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:38

    int is the same as System.Int32 and when compiled it will turn into the same thing in CIL.

    We use int by convention in C# since C# wants to look like C and C++ (and Java) and that is what we use there...

    BTW, I do end up using System.Int32 when declaring imports of various Windows API functions. I am not sure if this is a defined convention or not, but it reminds me that I am going to an external DLL...

提交回复
热议问题