Some knowledge points of C,

Source: Internet
Author: User

Some knowledge points of C,

  • It is not allowed to merge the encoding in the ref or out mode.

It seems that attention is similar to the field, but attention is essentially a method that does not really point to a memory location, therefore, it is not possible to merge rows in the ref or out mode like a field.

 

The atomicity of the anonymous type is always unknown.

 

Native value-type classes use the ToString method to avoid binning.

The former is more efficient than the latter, because the latter recognizes the mailbox. Therefore, when a value type involves string operations, the ToString method should always be used.

 

Type-wise and Inverse

Only interfaces and delegation can be used to identify these two features, which are not supported by classification (derived from the classification of class security ).

Future changes use out to repair the parent class. The opposite is the return value. If the parent class can be returned, the Child class can also be returned.

// Covariance.

IEnumerable <string> strings = new List <string> ();

IEnumerable <object> objects = strings;

The inverse Change uses in to repair the problem. The opposite is the regression number. The negative argument is: if the parent class can be imported, the Child class can also be written.

// Contravariant.

IComparer <object> objects = objectComparer;

IComparer <string> strings = objects;

Dynamic-type data can be converted into other types, but objects cannot.

For example, dynamic d = 1; int I = d;

The generator deems any operation on dynamic legal.

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.