C# native data types vs .NET CTS types
While coding we can use C# native data types as well as .NET CTS types. I am curious to know which data type should I use while declaring any variable. I found somewhere that we should use c# native datatype while I believe we should use CTS Type as in IL every data type is going to be in converted 开发者_开发知识库in respective CTS type. But I am not sure still which I should use? Let me know your views.
Thanks.
C# native types are compiled to EXACTLY the same IL code as their System.* counterparts.
So
int x = 1;
is exactly the same as:
Int32 x = 1;
See this question for the complete picture:
C#, int or Int32? Should I care?
The makers of the .NET framework recommend using the native C# types in the .NET Framework Design Guidelines book.
Jon Skeet outlines a few pros and cons in this answer.
精彩评论