Chapter 1:. NET Architecture (c # advanced programming version 6th) (unfinished)

Source: Internet
Author: User
Document directory
  • 1. Importance of strong data types in language interoperability
  • 2. Garbage Collection
  • 3. Security
  • 4. Application domain)
1.1 relationship between c # And. net
  • C # is specially designed for use with. NET.
  • C # is not part of. NET. Some features supported by. NET are not supported by c #. Some features supported by c # are not supported by. NET (such as operator overloading)
1.2 public Language Runtime Library
  • The core of. NET Framework is the execution environment of its runtime Library, which is called the common language runtime (CLR) or. NET runtime Library.
  • Generally, the code running under the control of CLR is called managed code ).
  • Compile the source code compiled by CLR. In. NET, compilation is divided into two phases:
    • (1) Compile the source code into an intermediate language (IL, intermediate language)
    • (2) CLR compiles IL into platform-specific code
  • Advantages of this design: platform independence improves performance and language interoperability.
1.2.1 platform independence

So far, the. NET platform has no knowledge of any possible cause, because currently. NET can only be used on Windows platforms.

1.2.2 improve performance

IL is always compiled in real time (called JIT compilation), which can improve the speed and performance.

  • Speed up: the JIT compiler does not compile the entire application once (this will take a long start time), but only the part of the code it calls. After the code is compiled once, the internal executable code is stored until the application exits. In this way, you do not need to re-compile the Code the next time you run the code.
  • Performance improvement: the last part of the compilation process is executed at runtime. the JIT compiler knows exactly what type of processor the program is running on, the final executable code can be optimized using any features provided by the processor or specific machine code commands.
1.2.3 language interoperability

Language interoperability: It can compile any language into intermediate code, and the compiled code can exchange with the Code Compiled by other languages.

1.3 intermediate language

Main features of intermediate language:

    • Object-oriented and user interfaces
    • The huge difference between the value type and the reference type
    • Strong Data Types
    • Handle errors with exceptions
    • Attribute)
1.3.1 support for object-oriented and interfaces
  • Interface: provides a contract. classes that implement a given interface must provide the methods and attributes specified by this interface.
  • C # language interaction:
    • Classes written in one language can inherit classes written in another language
    • A class can contain instances of another class, regardless of the language in which they are written.
    • One object should be able to directly call the method of another object written in other languages
    • Objects (or object references) can be passed between methods.
    • You can call these methods in different languages by debugging the source code written in different languages in the debugger.
1.3.2 different value types and reference types

For value types, the data is stored between variables, and for reference types, the variables only store addresses, the corresponding data can be found in this address.

1.3.3 strong data types
  • The intermediate language is based on a strong data type and generally does not allow any operation on the Fuzzy data type.
  • Although forced Implementation of type security will initially reduce performance, in many cases, we. NET provides more benefits from type-based security services, including:
    • Language interoperability
    • Garbage Collection
    • Security
    • Application domain
1. Importance of strong data types in language interoperability

If a class is derived from another class or contains instances of other classes, it needs to know all the data types used by other classes. This is the very important reason for strong data types.

For example, if another method in VB 2008 returns data of the Integer type, but c # does not have the data type of the name, if the compiler knows how to map the Integer type in VB to a known type defined by c #, the returned type can be used in c # code.

How does this problem be solved in. NET?

(1) CTS common type system)

  • CTS defines the predefined data types that can be used in intermediate languages. All object-oriented. NET Framework languages can generate final compilation code based on these types.

For example, Intger in VB 2008 is actually a 32-bit signed integer, which is actually mapped to the intermediate language type Int32, so this data type is specified in the intermediate language code. In the source code, c # uses int to represent Int32. Therefore, the compiler considers that the VB 2008 method returns an int value. (In c #, each predefined type recognized by the compiler is mapped to an IL built-in type, which is the same as VB 2008)

  • A rich type hierarchy is also defined, including well-designed locations where the Code allows you to define your own types.
  • The hierarchical structure of the general type system reflects the single inheritance of the intermediate language object-oriented method.

(2) CLS common language specification)

CTS and CLS work together to ensure language interoperability. CLS is a minimum standard and must be supported by all. NET-oriented compilers.

2. garbage collection 3. security 4. application domain 1.3.4 error 1.3.5 attribute usage 1.4 assembly 1.5. net Framework Class 1.6 namespace 1.7 created with C. NET application 1.8. C # In. NET Enterprise Architecture

 

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.