Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# native data types vs .NET CTS types

Tags:

c#

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.

like image 1000
marshalprince Avatar asked Oct 21 '25 02:10

marshalprince


1 Answers

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?

like image 100
Philippe Leybaert Avatar answered Oct 22 '25 15:10

Philippe Leybaert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!