C # Advanced Programming

Source: Internet
Author: User

There is a C # High-group programming in hand. I keep saying that I want to watch it, but it's always because it's not complicated. Now I'm going to start writing.

Chapter 1

. Net Architecture

We cannot use the C # language in isolation, but must consider it together with the. NET Framework. The C # compiler is dedicated to. Net, which means that all code written in C # is always run in. NET Framework. For C # language, two important conclusions can be drawn:

(1) the structure and methodology of C # reflect the. NET basic methodology.

(2) In many cases, C #'s specific language functions depend on. NET functions, or on. NET base classes.

Because of this dependency, it is very important to understand the structure and methodology of. net before using C # programming. This is the purpose of this chapter. The content of this chapter is as follows:

1. This chapter first describes what happens when. Net compiles and runs all the code (including C.

2. After an overview of the content, we need to elaborate on Microsoft intermediate language (msil or IL) in detail. net should be used for all compiled code. This chapter introduces how common language specification (CLS) provides interoperability between. NET languages. Finally, explain how to use net in various languages, including Visual Basic and C ++.

3. We will introduce other features of net, including assembly, namespace and. . Net.

4. In the last chapter, we will discuss the types of applications that C # developers can create.

1. 1c # And. Net relationship

C # is a quite new programming language. The importance of C # is embodied in the following two aspects:

1. It is specially designed for use with Microsoft's net framework. (Net Framework is a platform with rich functions. It can be used to develop, deploy, and execute distributed applications)

2. It is a language based on modern object-oriented design methods. When designing it, Microsoft also draws on the experience of other similar languages, these languages were developed after the application of object-oriented rules in the past 20 years.

There is a very important question to understand: C # is just a language in itself, although it is used to generate oriented. net Environment Code, but it is not. net ,. some features of net support, C # is not supported, and C # supports other features ,. Net does not support (such as operator overloading)

However, because C # Is.. net.

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 Library (CLR) or. Net Runtime Library, usually the code running under the control of CLR is called managed code ).

However, you need to compile them (in C # or other languages) before executing the compiled source code in CLR. Net, compilation is divided into two phases:

1. Compile the source code into Microsoft intermediate language (IL ).

2clr compiles il into dedicated code for the platform.

The compilation process in these two phases is very important, because Microsoft intermediate language (managed code) is co-operative. Net.

The micfosoft intermediate language shares a concept with Java Byte Code: they are both low-level languages and have simple syntax (using digital code instead of text code), which can be quickly converted to internal machine code. For code, this well-designed general syntax has an important advantage: platform independence, improving performance and language interoperability.

1.2.1 platform independence

First, this means that the same file containing byte code instructions can be placed on any one platform, and the final stage of the compilation process during running can be easily completed, so that the code can be used on a specific platform. In other words, you can obtain it by compiling it into an intermediate language. . NET platform independence, which is the same as compiling JAVA byte code.

Note. NET platform independence is currently only one possibility, because when writing a book ,. Net can only be used on Windows platforms, but people are actively preparing to make it available for other platforms (see Mono Project, which is used to implement. Net open source code

1.2.2 improve performance

In the previous comparison between hydrogen Il and Java, in fact, Il is more effective than Java byte code, and IL is always compiled (called JIT compilation), while Java byte code is often interpreted, one disadvantage of Java is that the process of converting JAVA byte code to internal executable code during application running will lead to performance loss (but recently, java can be compiled by JIT on some platforms.

The JIT compiler does not compile the entire application once (this will take a long start time, But compile only the part of the Code called by it (this is the name of its origin, the internal executable code is stored until the application is exited, so that the next time you run the code, you do not need to re-compile it, micfosoft believes that this process is much more efficient than compiling the entire application code at the beginning, because most of the code of any application is not actually executed during each running process, using the JIT compiler, this type of code is never compiled.

This explains why the execution of the hosted il code is almost as fast as that of the internal machine, but does not explain why Microsoft thinks this will improve performance, the reason is that 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.

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.