The C # language cannot be used in isolation, but must be considered together with. NET Framework.
The structure and method of C # reflects the. NET basic methodology.
In many cases, the function of C # depends on the function of. Net or the. NET base class.
1.1 relationship between C # And. net
(1) C # is designed specifically for use with Microsoft's. NET Framework.
(2) Language Based on Modern object-oriented design methods.
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 run under the control of CLR Code It is called managed code.
In. net, compilation is divided into two phases:
(1) Source code Compile to msil.
(2) CLR compiles msil into platform-specific code.
Advantages of managed code:
(1) platform independence
(2) improve performance (JIT only when needed), compile multiple executions at a time (until the application Program ).
(3) language interoperability.
1.3 intermediate language
All. Net-oriented languages must logically support the main features of Il.
The following are the main features of the intermediate language:
(1) Object-oriented and user interfaces
(2) the huge difference between the value type and the reference type
(3) Strong Data Types
(4) handle errors with exceptions
(5) use features)
1.3.1 object-oriented and Interface Support
Microsoft chose traditional Object-Oriented Programming for IL, with a single inheritance of classes.
The true meaning of language interoperability is that classes written in one language should communicate directly with classes written in another language.
1.3.2 different value types and reference types
1.3.3 strong data types
An important aspect of interlanguage is that it is based on strong data types. Generally, the intermediate language does not allow any operation on the Fuzzy data type.
1.3.4 handle errors through exceptions
1.3.5 usage of features
1.4 assembly
An assembly is a logical unit (not a physical unit) that contains compiled. NET Framework-oriented code ).
An important feature of an assembly is that the metadata they contain describes the types and methods defined in the corresponding code. An assembly also contains metadata that describes the Assembly itself.
There are two types of assemblies: Shared assemblies and private assemblies.
1.4.1 private assembly
Private assembly is the simplest assembly type. Private assembly is generally attached to a software and can only be used for the software.
1.4.2 shared assembly
Shared assembly is a public library that can be used by other applications.
1.4.3 reflection
Because the Assembly stores metadata, including the types defined in the Assembly and the details of these type members, you can program access these metadata. This technology is called reflection.
1.5. Net Framework class
From the developer's perspective, the biggest advantage of writing managed code is that you can use the. NET base class library.
The. NET base class is a rich collection of hosted code that can complete the vast majority of tasks previously completed through windows APIs.
. Net2.0 and 3.0 base classes include:
The core functions provided by IL, for example, basic data types in general type systems.
Windows GUI support and controls
Web forms (ASP. NET)
Data Access (ADO. Net)
Directory Access
File System and Registry Access
Network and web browsing
. NET features and reflection
Access all aspects of the Windows operating system (such as environment variables)
Com interoperability
Most. net base classes are actually written in C.
1.6 namespace
Namespace is a method for. Net to avoid class name conflicts.
1.7 use C # To create a. NET application
1.7.1 create an ASP. NET application
1. ASP. NET features
ASP. NET pages are structured, and each page inherits the system. Web. UI. Page class of the. NET class.
2. Web Forms
3. XML Web Service
1.7.2 create a Windows form
1.7.3 use Windows Presentation Foundation (WPF)
WPF uses XAML when creating an application. XAML indicates the Extensible Application Markup Language.
1.7.4 Windows controls
1.7.5 Windows Services
Windows service is a program running in the Microsoft operating system background.
1.7.6 windows Communication Foundation (WCF)
1.8 C # role in. NET Enterprise Architecture