C # Introduction to the. NET Framework

Source: Internet
Author: User

C # Is a concise and type-safe object-oriented language. developers can use it to build a variety of secure and reliable applications running on the. NET Framework. With C #, you can create traditional Windows client applications, XML Web Services, distributed components, client-server applications, database applications, and many other types of programs. Microsoft Visual C #2005 provides an advanced code editor, a user-friendly interface designer, an integrated debugger, and many other tools in C #2.0 and.. NET Framework.

Note:

The Visual C # document assumes that you understand basic programming concepts. If you are a beginner, you may need to learn about the Visual C # Quick version, which can be downloaded from the website. You can also use any excellent books and web resources on C # To learn practical programming skills.

C # Language

C # Strong syntax, less than 90 keywords, and easy to learn. C #'s braces make anyone familiar with C, C ++, or Java get started immediately. Developers who understand any of the above languages can usually start to use C # efficiently in a short period of time. The C # syntax simplifies the complexity of C ++ and provides many powerful functions, such as empty value types, enumeration, delegation, anonymous methods, and direct memory access, these are not available in Java. C # also supports generic methods and types to provide better type security and performance. C # also provides an iterator that allows the set class implementers to define custom iteration behaviors, simplifying the use of client code.

As an object-oriented language, C # supports encapsulation, inheritance, and polymorphism. All variables and methods, includingMainMethods (Application entry points) are encapsulated in class definitions. A class may be inherited directly from a parent class, but it can implement any number of interfaces. Methods that override Virtual Methods in the parent class require the override keyword as a way to avoid accidental redefinition. In C #, the structure is similar to a lightweight class. It is a type of stack allocation and can implement interfaces, but does not support inheritance.

In addition to these basic object-oriented principles, C # accelerates the development of software components through several innovative language structures, including:

  • The encapsulated method signature (called a delegate) implements type-safe event notification.

  • Property to act as an accessor for private member variables.

  • Attribute provides declarative metadata about the runtime type.

  • Inline XML document comments.

In C #, if you need to interact with other Windows software (such as a COM object or a local Win32 DLL), you can use a process called "InterOP. Interoperability enables the C # program to complete almost any task that the local C ++ application can complete. When direct memory access is essential, C # Even supports the concept of pointers and "insecure" code.

The C # generation process is simpler than C and C ++, and more flexible than Java. There is no separate header file, and methods and types are not required to be declared in a specific order. C # The source file can define any number of classes, structures, interfaces, and events.

. NET Framework Platform Architecture

C # The program runs on. NET Framework. It is a necessary component of windows, including a virtual execution system called the Common Language Runtime (CLR) and a unified class library. CLR is a commercial implementation of Microsoft's Common Language infrastructure (CLI. CLI is an international standard and is the basis for creating a language and library to seamlessly work together in the execution and development environment.

The source code written in C # is compiled into an intermediate language (IL) that complies with CLI specifications ). The IL code and resources (such as bitmap and string) are stored on the disk as an executable file called an assembly. The extension is. EXE or. dll. An Assembly contains a list that provides information about the assembly type, version, culture, and security requirements.

When the C # program is executed, the Assembly is loaded into the CLR, which may perform different operations according to the information in the list. Then, if security requirements are met, CLR executes real-time (JIT) compilation to convert the Il code into local machine commands. CLR also provides other services related to automatic garbage collection, exception handling, and resource management. Code executed by CLR is sometimes referred to as "managed code", which corresponds to the "unmanaged code" compiled for the native machine language of a specific system. Demonstrates the relationship between C # source code files, base class libraries, Program sets, and CLR compilation and runtime.

Language interoperability is a key function of. NET Framework. Because the Il code generated by the C # compiler conforms to the common type specification (CTS ), therefore, the Il code generated from C # can be.. Net or any of the other 20 Cts-compliant languages can generate code for interaction. A single assembly may contain multiple modules written in different. NET languages, and the types can be referenced by each other, just as they are written in the same language.

Besides the runtime service ,. NET framework also contains a detailed library composed of more than 4000 classes, these classes are organized as namespaces, provides a variety of useful functions for all content from file input and output to string operations, to XML analysis, to Windows Forms controls. Typical C # applications use the. NET Framework class library to widely process common "Daily" tasks.

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.