Down-to-earth learning C #1-primitive type

Source: Internet
Author: User
Tags mscorlib

Primitive type: Data Types directly supported by the compiler

The primitive types are directly mapped to the FCL class library. For example, int and Int32 are equivalent, except that int is provided by c # And Int32 is provided by the FCL class library.

Int is only the alias of Int32.

Using int = System. Int32;

Use Int32:

System. Int32 number = new System. Int32 ();
Number = 2;
Console. WriteLine (number );
Console. ReadKey ();

The generated IL code is:

   static  Main([] args)                    ]                                                          [mscorlib]System.Console::WriteLine(                    

Use int

Int number = new int ();
Number = 2;
Console. WriteLine (number );
Console. ReadKey ();

The generated IL code is:

   static  Main([] args)              ]                                        [mscorlib]System.Console::WriteLine(              

By comparing the generated IL code, we found that the IL code generated by int and Int32 is the same.

The above number assignment syntax is inconvenient. I believe no one will. Fortunately, the compiler allows the code to manipulate them with simplified syntax,

Int number = 2; // C # simplified syntax
Int32 number = 2; // The simplified Syntax of FCL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.