C # Learning Series-. NET architecture,

Source: Internet
Author: User

C # Learning Series-. NET architecture,

. NET Framework Overview

The. NET Framework provides a virtual machine environment for. NET application programs and services such as compilation, running, memory management, garbage collection, and security for. NET applications.

 

. NET Framework components

1. Common Language Runtime (CLR)

2. NET Framework class library (not all class library codes in the. NET Framework are purely managed code written, and a considerable number of classes in the. NET Framework are encapsulated for Win32 APIs)

 

Managed code

Code provided when running in. NET public language, and vice versa (for example, Win32 API)

 

Common Language Organization Framework (CLI Common Language Infrastructure)

Specifying how to declare, use, and manage types in the Runtime Library is also an important part of the Runtime Library's support for cross-language interoperability

1. Build a framework that supports cross-language integration, type security, and high-performance Code Execution

2. Provides an object-oriented model that supports complete implementation of multiple programming languages.

3. Defining rules that must be followed by each language helps ensure that objects written in different languages can interact with each other

 

Common Language Runtime (CLR)

Manages. NET application compilation, running, code type security check, memory allocation, thread management, security, garbage collection, and other services to provide a virtual runtime environment for. NET applications.

 

CTS Common Type System)

CTS defines a Type Library. Both VB and C # have the same data types. NET abstracts the data types of different programming languages, and CTS is born.

CTS type mainly divided into: Value Type and reference type http://wenku.baidu.com/link? Url = Response

 

CLS Common Language Specification)

CLS is a subset of CTS. The goal is to allow objects written in different programming languages on the. NET platform to call each other.

 

The relationships among CTS, CLR, and CLS are as follows:

 

Value Type:The memory is stored in the memory stack for fast access. The memory is automatically released beyond the permitted range. The garbage collection mechanism does not participate in the collection.

Reference Type:Allocated in memory. The default value is NULL. The address of the memory allocated in the stack is searched through the pointer during the operation and collected through the garbage collection mechanism. When the content of a referenced type variable is assigned to another referenced type variable, only the memory address of the variable is copied.

 

Packing: Convert the value type to the reference type int I = 0; object o = I;

Unpack: Convert the reference type to the value type int I = 0; object o = I; int j = (int) o;

Packing and unpacking have an impact on performance loss.

 

JIT)

NGEN (native image builder) Compilation

The local image generator (ngen.exe) is a tool to improve the performance of hosted applications. Ngen.exe creates local images (files containing compiled processor-specific machine code) and installs them in the local machine image cache. The runtime can use a local image from the cache, rather than using a real-time compiler to compile the original assembly.

 

Intermediate Language)

 

Refer to C #4.0 authoritative guide


C language ^ how to use

A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010

B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011

^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.

//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].

C language ^ how to use

A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010

B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011

^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.

//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].

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.