C # and the. NET Framework before. Net
. NET ERA. NET Framework composition
Greatly improved programming environment compiled into CIL
Compile the cost machine code and execute
CLR Common Language Runtime
CLI Common Language Infrastructure
Various abbreviations
C # Evolution of C # and the. NET Framework before. Net
The 1990s, Microsoft platform most programmers use VB, C or C + +. There are problems with the technology they use.
Technology |
problem |
Pure Win32 API |
Not object-oriented, much more work than MFC |
MFC (Microsoft Foundation Class, Microsoft Basic Library) |
Object-oriented, but inconsistent, and too old |
COM (Component object model, Component object models) |
Although the concept is simple, but the actual code is complex and ugly |
Problems |
The above technologies are developed for desktop applications and are very different from web programming |
This leads to the goals of the next generation platform
. NET Era
. NET Framework Features
- Multi-platform
- Use industry-standard communication protocols
- Provides a more secure execution environment
. The composition of the NET Framework
CLR (Common Language Runtime, Common language runtime)
- Memory Management and garbage collection
- Code Security Verification
- Code execution, thread management, and exception handling
Programming tools cover everything you need to encode and debug
- Visual Studio IDE
- . NET-compatible compilers
- Debugger
- Web site development server-side technologies such as ASP. NET or WCF
BCL (base Class Library): A large class library used by the. NET Framework
Vastly improved programming environment
- Object oriented
- Automatic garbage collection
- The CLR has a GC (garbage Collector, garbage collector) that automatically manages memory for you. (Automatically removes objects from memory that the program no longer accesses)
- Interoperability
-
- . NET language allows seamless interaction between software modules written in different. NET languages
- A. NET language programs can use or even inherit classes written in another. NET language, just follow certain rules
- Because it is easy to integrate modules generated by different programming languages. NET Framework is sometimes called language-independent
- . NET provides platform invoke (platform Invoke,p/invoke): Allow. NET code calls and uses non-. NET code. It can use the pure C function code exported by the standard Win32 DLL, such as the Windows API
- . The NET Framework allows for interoperability with COM:. NET Framework components can invoke COM components, and COM components can also invoke. NET components.
- Do not need com
- Getting rid of COM can also get rid of these things, but there are still a lot of COM components in the system, so occasionally you need to write code to interact with these components, which is discussed in Chapter 25
- IUnknown interface
- Type library
- Manual reference count
- HRESULT
- Registration Form
- Simplified deployment
-
- . NET program does not require a registry, meaning that in the simplest case, replication can be used in the past.
- . NET provides the characteristics of parallel execution, allowing different versions of a DLL to exist on the same machine. That is, each program can access the version DLL that is used when the program is built
- Type safety
- CLR checks and ensures the type safety of parameters and other data objects, and there is no problem between components written in different programming languages
- Base Class Library
- . NET Framework provides a large base class library (base classes LIBRARY,BCL). Classes can be used when writing a program
- Common base classes: A powerful set of tools, such as file manipulation, string manipulation, security, and encryption.
- Collection classes: Lists, dictionaries, hash lists, and bit arrays
- Threading and Synchronization Classes: for creating multi-threaded threads
- XML classes: For creating, reading, and manipulating XML documents
Compile into CIL
- The assembly is either executable or DLL
- The code for the assembly is not native code, but is an intermediate language called CIL (Common intermediate laguage, Common Intermediate language)
- The assembly contains the following content
- CIL of the program
- Metadata for the type used in the program
- Metadata for other assembly references
CIL is also called IL (intermediate Language) or MSIL (Microsoft intermediate Language)
Compile the cost machine code and execute
The CIL of the program is not compiled until it is called to compile the cost machine code. At run time, the CLR performs the following steps
- Check assembly security Features
- Allocating space in memory
- Sends the executable code in the assembly to the real-time (just-in-time,jit) compiler, which compiles some of the cost machine code
Once CIL is compiled with the cost machine code, the CLR manages it as it runs, performing tasks such as freeing up non-primary memory, checking array boundaries, checking parameter types, managing exceptions, and so on. At the same time, two terms are born.
- Managed code: for. NET Framework, requires the CLR
- Unmanaged code: Code that is not running under CLR control, such as the Win32 C + + DLL
Compiling and executing
CLR Common Language Runtime
The CLR is on the top level of the operating system, responsible for managing program execution
The following services are also available
- Automatic garbage collection
- Security and Certification
- Extensive programming capabilities, including features such as Web services and data services, are obtained by accessing the BCL (base class Livrary)
CLI Common Language Infrastructure
The built-in types of programming languages were different in the past due to language and platform differences.
For example, the number of digits that make up an integer varies widely between languages and platforms.
For unified collaboration, there must be a set of standards, which is the CLI (Common Language Infrastructure, common Language Infrastructure)
An important part of the CLI
- Public type System
The CTS (Common type System, public type systems) defines the type characteristics that must be used in managed code.
- Defines a rich set of built-in types, as well as inherent, unique features for each type
- . NET compatible programming language typically maps to a particular subset of the built-in type set defined in the CTS
- All types of CTS inherit from the public base class-object
- Using CTS ensures that system types and user-defined types can be used with any. NET language compatibility
- Common Language Specification
The CLS (Common Language specification, Common Language Specification) describes one detail. The rules, properties, and behaviors of the net-compatible programming language include data types, class structures, and parameter passing.
Various abbreviations
Evolution of C #
version |
Focus Characteristics |
Chapters |
5.0 |
Asynchronous |
20 |
4.0 |
Named parameters and optional parameters |
5 |
3.0 |
Linq |
19 |
2.0 |
Generic type |
17 |
1.0 |
C# |
|
PS: Finally attach a PDF scan version of this book
C # Schematic Tutorials chapter I C # and. NET Framework