C#oop 14 Introduction to the. Net Framework

Source: Internet
Author: User

. Net FrameWork


From the previous DOS platform to today's Windows 2003, Vista, Win7, the development of language is also blossoming, choose which one, in the end which is the best? The more painful is the consistency of the development language between members of the team, inconsistent words, VC + + The development of the class Library file Delphi, can not be adjusted, and vice versa, can not be good to implement code reuse, efficiency, etc., have to look for the pain of the Windows API and other huge thick manuals, treasure, their own re-written class library and so on to call.

So there is no better technology to achieve the common between the various languages? Team members are no longer confined to language problems, and the. Net Framework is the product of the season.

The. NET Framework, also known as the. NET frameworks, consists of two main components: the common language Runtime (CLR) and the Framework class Library set (FCL).

C #, VB, VC + +, J #

Visual Studio.NET IDE

Common Language Specification (CLS)

. Net 3.0, 3.5 4.0 components (WPF, WWF, WCF)

ASP. NET, ADO, Winform, WinCe

Base Class Library (FCL)

Common language Runtime (CLR)

Windows XP, WindowsVista, Windows7 operating systems

Common Language Runtime: CLR

The original programming language is for the platform, such as Windows, Linux, and now from C #, Java, a new program language execution, is the "intermediate code + Virtual machine" execution mechanism. This intermediate code cannot be executed directly, it requires a "virtual machine" device to be managed and executed, so that interpretation execution can also be performed by the compiler. As shown in the following:



The virtual machine that manages and executes intermediate code in the. Net framework is the common language runtime (CLR), which is responsible for managing and executing the. The intermediate code generated by the net compiler.

The execution process is as follows:

ü Writing C # code in the development environment visualstudio.net

ü Compiler compiles code into intermediate language Code (intermediate languages are similar to assembly language, but not machine code)

ü The intermediate language code is managed and executed by the CLR.

Note that another role of the common language runtime is that it is easy to implement cross-platform (provided that the. Net FrameWork is installed on the operating system, and Microsoft does not advocate cross-platform (cross-platform impact on the Windows operating system market monopoly), But now there is a platform for running and editing. NET programs in the Linux operating system, mono (containing the C # compiler, CLR, and FCL)



Microsoft intermediate Language--msil

. What is an intermediate language? Suppose we have three scholars in Chinese, Japanese and French who are exchanging a question, how should we communicate? If there is a language they know (English, sign language, or Esperanto) to communicate, they can understand each other.

In. NET intermediate languages are similar to real English, sign language or Esperanto, it is because of VB, C #, J #, VC + + and other programming languages are compiled into intermediate languages, the CLR eventually executes the intermediate language, so there is a language-independent problem.

Language independence is the meaning of. NET Framework produces the final code that is independent of the specific programming language and is only relevant to the intermediate language. Regardless of which programming language you use, you will eventually become an intermediate language, which is equivalent to any language you use in VB or C #. It is now much easier to write to members using VB or C # in the company team, and they can call each other's things. The benefits are considerable, saving our learning time for different programming languages, and putting more effort into the business logic of the program.



CTS and CLS

The CLS is known as the Common Language specification, which is used to define. NET language should adhere to the rules. The CTS is called a common type system, and it typically contains standard data types and so on.

The CLS defines the minimum set of attributes for a. NET programming language (C #, VB, VC, and so on) data types, and only value types or reference types that are defined by a programming language that follows the CLS are referenced by other programming languages. For example, you can define a method for the Uint32 return type in C #, but this data type is not required by the CLS, so calling this method in VB can cause trouble or create an error. That is, the premise of ensuring interoperability of different language programs is to program using the data types specified in the CLS.

The CTS can be said to be a complete collection of. NET features, and you can see in the right-hand image that the type of a programming language is just a subset of the CTS. If you are programming directly with IL, then you can use all the features of the CTS, and if you use C #, then you can only use the part of the type or guideline that the CTS contains for C #.



The CTS describes the definition of language in the. NET environment and how it behaves, and a language must conform to the requirements of the CTS in order to run into the. NET environment. For. In any language in net, the syntax for how classes are defined, inherited syntax, or even the life cycle of an object is the CTS rule.



. NET base Class Library (FCL)

. In. NET, Microsoft has provided a powerful class library for a wide range of applications to easily develop programs. About the concept of class library has always existed, the previous VC has MFC Class Library, Delphi has VCL class library, Java has swing, SWT and other class libraries. These class libraries encapsulate the underlying functionality of the system and provide a better way to operate.

. The class library in net encapsulates the processing function of Windows, network, file, multimedia, is all. NET language must use the core class library. Using the. NET Basic Class library (FCL) in Visual Studio, we can develop the following six types of applications:

n Windows Forms applications

N Windows Console Application

N XML Web Service

N ASP. NET Web Forms application

N Windows Services

N. NET components

The FCL class library has about 7,000 classes (each class may have hundreds of methods or properties, more than the original 18,000 Win32 API appears more powerful), do not look at many, clear ideas and the context, all the way to one, learning is not difficult.

To get to the chase, these classes are separated by namespace (the namespace is the class classification). The commonly used class libraries are as follows:

namespace

Description

System

Includes the most basic classes that provide data types, events and event handling, interfaces, properties, exception handling, and so on.

System.Drawing

Working with graphics and drawings, including printing

Syst Em. Data

Deals with access and management, plays an important role in defining ADO

System.IO

Tube Synchronous and asynchronous access to files and streams

system.windows

Process form-based window creation

System.Reflection

Contains a class that reads metadata from an assembly

System.Threading

Contains classes for multithreaded programming

System.Collections

Contains interfaces and classes that define various sets of objects

System.Net

Provides classes for network traffic, such as peer-to-peer communication, network chat, and so on

Why Choose C # to see how difficult it was to develop a simple form planner under Win32. The code is as follows:

To display a form's program using the Windows API:

HWND Hwndmain = CreateWindowEx (

0, "Mainwinclass", "Main window",

Ws_overlappedwindow | Ws_hscroll | Ws_vscroll,

Cw_usedefault, Cw_usedefault,

Cw_usedefault, Cw_usedefault,

(HWND) NULL, (HMENU) null,hinstance, NULL);

ShowWindow (Hwndmain, Sw_showdefault);

UpdateWindow (Hwndmain);

A program that displays a form under the. NET Framework using C #:

Form form = new form ();

Form. Text = "Main Window";

Form. Show ();





Other industries are no longer listed, in short, used. NET for enterprise-level development, game customization, User Services more and more, has been applied to all aspects of society.



Summary:

In this chapter, we have mainly studied:

U what is. NETFramework

U CTS and CLS Concepts

U. Net Framework Industry Applications



English vocabulary:

English full text Chinese

CLR Commonlanguage Runtime Common Language runtime

FCL Foundationcommon Library base class libraries

MSIL microsoftintermediatelanguage Microsoft intermediate language

CTS Common type System public type systems

CLS Common Language Specification Common Language Specification



Practice Items:

Use MSDN to learn some details about MSIL, CTS, and CLS, and summarize them.


C#oop 14 Introduction to the. Net Framework

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.