Basic concepts of the. Net Framework (Reading Notes -- opening the door to C)

Source: Internet
Author: User

I have been confused about the. Net Framework. Today I saw this chapter and finally helped me sort out my ideas.

First, the. Net Framework should be understood as the code execution environment: on the one hand, it manages the code execution process, and on the other hand it provides class library support for the code.

Common Language Runtime (CLR) is the process of managing code execution. It is responsible for running code, ensuring code security and accuracy, and managing core tasks such as memory and thread scheduling. Generally, we call the code running under the control of CLR as managed code.

The. Net Framework basic class library (FCL) is a supporter of the Code class library.

2. Relationship between C # And. Net

C # source code -- compile -- Microsoft intermediate language (MSIL) -- after JIT (instant compilation) -- machine language.

JIT improves performance: JIT compilation occurs when the program is running.

MSIL provides the possibility of language interoperability: Components written in different languages are eventually compiled into intermediate languages and then formed into a complete program.

In theory, msil can run on any operating system with the. net Framework installed.

Third, CTS common type system and common language specification (CLS)

I have never wondered why C # uses Int and Int32 to represent the same type. Now I understand. INT32 is the type of the MSIL language -- CTS type -- Standard Basic Data Type of the general type system, but there are different Representation Methods in different languages. For example, in C #, It is INT, and in C ++ it is (sign) int. that is to say, whether it is C # int or C ++ (sign) int, it is eventually compiled into the INT32 type of MSIL.

A general type system not only specifies the basic data type, but also defines a rich type hierarchy.

CLS is a language standard supported by all. NET languages. That is to say, the syntax rules in the common language standards are established in all. NET languages. They are the intersection of the syntax rules supported by all. NET languages. Therefore, the Code conforming to the CLS specification can be accessed by any language on. NET after being converted to an intermediate language, thus ensuring the interoperability of different languages. Of course, writing code that does not comply with CLS specifications is also possible, but it cannot ensure interoperability between different languages.

Type determination:

Sizeof: obtains the number of bytes of the Data Type in the memory. However, you cannot obtain the number of bytes of the Data Type of the defined class.

Typeof: Get the CTS type name of the data type, so the start parameter can only be type. That is, the type after being compiled into an intermediate language. You can also obtain the custom type.

GetType: Get the type of a variable.

Is OPERATOR: checks whether an object is of a certain type. It is somewhat similar to GetType, but when the object and type are inherited, the is Operator returns TRUE.

Namespace: The namespace is used to organize classes and avoid duplicate names of two class libraries.

 

Packing and unpacking:

Value Type -- reference type: boxed (hidden)

Reference Type -- Value Type: binning (display conversion)

Object equality:

ReferenceEquals () and Equals () and equal operators (= ):

ReferenceEquals () and Equals () are referenced by default, but we can override Equals () to compare the value type;

Equality operator (=): by default, if two objects are of the value type, compare the values. If the two objects are of the reference type, compare the references. However, we can change it using the method of the overload operator.

 

 

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.