The c#3.0 and net3.5 of "c#3.0 in a nutshell,3rd Edition" Basic introduction

Source: Internet
Author: User
Tags garbage collection inheritance thread

Objective

C#3.0 is an object-oriented programming language, which has many features such as multi-purpose and type safety. In order to realize the efficiency of development and learning, she has made great efforts in language simplicity, ease of expression, and programmability. Allowing newcomers to get started quickly, developers can quickly develop programs. But these are not the premises that impair the function of language.

Body

Object-oriented (object orientation) of one section C #

C #, like Java, is an object-oriented language with features such as encapsulation (encapsulation), polymorphism (polymorphism), inheritance (polymorphism). But she also has the distinguishing features of other object-oriented languages.

A. Unified type systems (Unified type System)

That is, all types (type) are shared as a common base type (Common base type). Either the value type or the reference type is inherited from the System.Object. And all types of methods owned by the object can be used, such as: ToString (), Equals () and so on.

B. Classes (class) and Interfaces (Interface)

In the traditional object-oriented language, there is only one manifestation of class, whereas in C # (Java) there is an interface (Interface), an interface is a class that has only a definition that is not implemented, and since C # is a single class inheritance language, interfaces are particularly useful, and a class can inherit multiple interfaces, Make up for the lack of single class inheritance. (Single class inheritance should be done intentionally by the language designer, presumably to keep the class pure).

C. Attributes (properties), Methods (Methods), and events (event)

The traditional Image object language is only methods, and C # has added attributes and methods, which enrich our programming, especially when it is useful to do some component and control development.

Type safety for two section C # (type Safety)

C # is a strongly typed language, which means that you define the method of int parameters without using the float parameter to invoke it. The compiler (Complier) is forced to do type checking, and the mismatched type throws an exception (Exception) and prompts for an error, as is the definition of the variable. With the powerful IDE capabilities of VS, the IntelliSense feature has been provided, allowing us to troubleshoot these errors in advance.

In addition, Var appears in c#3.0, but it is also a strong type, and the compiler infers her type based on the context.

Three section. NET Memory management (Memory Management)

C # runs on a run-time (Common lanague Runtime), the CLR has powerful features that help us manage the memory used by the program. She has memory management, garbage collection, thread management and other functions. This is convenient for us to program, do not need to think C + + as the need to write a large number of their own code to release resources, so there is no memory leak in theory.

But I personally feel better not to be lazy, like some expensive resources or manual release parity, such as: The call to the printer, as well as multithreading management. Defensive programming is still needed.

CLR garbage collection is generally two threads to operate, for the normal object of the collector is the direct overlay stack, and for the more expensive resources temporarily can not be recycled, will be placed on another thread, wait until the arrival of the security point to recycle. This can be found on the Internet to find introductory information.

Multi-platform support for four section C # (Platfrom Support)

Both C # and the CLR are compliant with ECMA standards. C # 's code is usually run on the Windows platform, but it doesn't prevent her from running on other systems such as Linux, Solaris, MAC OS X. NET Framework provides us with a unified programming model, so we just need to program. There is no need to consider the difference of the system.

C # 's code can also run on the Silverlight host, a new technology introduced by Microsoft.

Five section C # and Common Language runtime (CLR) relationships

C # is one of the many languages running on the CLR, and she relies on services such as memory management provided by. NET.

Six section Common Language Runtime (CLR) and the. NET Framework Relationships

The. NET Framework is composed of the CLR and a large array of classes. This huge class library is divided into core classes (cores libraries) and application classes (applied libraries), which are based on core classes.

Figure: (Picture from book)

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.