当前位置:网站首页>Chapter I: Net architecture (1)
Chapter I: Net architecture (1)
2022-06-11 05:05:00 【Skill code brother】
1、C# And .NET The relationship between
C# The compiler is designed for .NET, This means using C# All the code you write is always .NET Framework Run in . about C# language , Two important conclusions can be drawn :
(1)C# The structure and methodology of .NET Basic methodology .
(2) in many instances ,C# The specific language functions of depend on .NET The function of , Or depend on .NET Base class .
C# The importance of is reflected in the following two aspects :
- It is dedicated to Microsoft Of .NET Framework Designed for use with (.NET Framework It is a platform with rich functions , Developable 、 Deploy and execute distributed applications ).
- It is a language based on modern object-oriented design method , When designing it ,Microsoft It also draws on the experience of all other similar languages .
C# In itself, it's just a language , Although it is used to generate oriented .NET The code of the environment , But this province is not .NET Part of ..NET Some features supported ,C# Does not support . and C# Other features supported by the language ,.NET But I do not support ( Such as operator overloading )!
2、 Common language runtime
.NET Framework The core of is its runtime execution environment , It's called the common language runtime (CLR) or .NET Runtime . Usually will be CLR Code that runs in control is called managed code (managed code).
however , stay CLR Execute the written source code ( Use C# Or code written in other languages ) Before , They need to be compiled . stay .NET in , Compilation is divided into two stages :
(1) Consider the source code as Microsoft Intermediate code (IL).
(2) hold CLR hold IL That is, the platform specific code .
Microsoft Interlanguage and Java Keywords share an idea : They are all low-level languages , The grammar is very simple ( Use numeric codes , Not text code ), It can be converted to local machine code very quickly . For code , This well-designed general syntax has important advantages : Platform independence 、 Improve performance and language interoperability .
2.1、 Platform independence
First , This means that the same file containing bytecode instructions can be placed on any platform . The final stage of the run-time compilation process can be easily completed , In this way, di'ama can run on a specific platform . In other words , I thought that the intermediate language could be obtained .NET Platform independence , This is the same as thinking Java Bytecode will get Java Platform independence is the same .
2.2、 Improve performance
actually ,IL Than Java Bytecode is even more important .IL Always compiled on the fly ( be called JIT compile ), and Java Bytecode is often interpretative .Java One of the disadvantages of , When running the application , hold Java The process of converting bytecode to internal executable code will lead to the loss of myocardial infarction .
JIT The compiler does not compile the entire application at once ( This will have a long start-up time ), Instead, compile only the part of the code it calls ( This is the origin of its name ). Once the code has been compiled , The resulting local executable is stored , Until you exit the application , So the next time you run this part of the code , There is no need to recompile .
trusteeship IL Code executes almost as fast as native machine code , The reason is that the last part of the compilation process is done at run time ,JIT The compiler knows exactly what type of processor the program is running on , Any features or specific machine code instructions provided by the processor can be used to optimize the final executable code .
Traditional compilers optimize code , But their optimization process is independent of the specific processor running the code . This is because the traditional compiler compiles the executable code of the local machine before releasing the software . That is, the compiler does not know the type of processor running the code ,
1.2.3、 Language interoperability
Use IL Not only does it support platform independence , It also supports language interoperability . In short , Is to be able to compile any language into an intermediate language , Code compiled into an intermediate language can interoperate with code compiled from other languages .
(1)VB
(2)VC++
C++ An interesting problem with is when compiling into managed code , The compiler can generate a program that contains embedded local executables IL. This means that in C++ You can combine gate types and unmanaged types in your code , So trusteeship C++ Code :
class MyClass
Defines a common C++ class , The code :
ref class MyClass
Generated a managed class , It's like using C# or VB2012 Just like writing classes . actually , trusteeship C++ Code ratio C# The better thing about the code is that it can be hosted C++ Calling unmanaged... In code C++ class , Instead of this Yong COM Interoperability features .
If you use... On managed types .NET Unsupported feature ( for example , Multiple inheritance of templates or classes ), The compiler will get an error . in addition , When using the exit class , You also need to use non-standard C++ function .
Written using .NET Of C++ The program will get several different interoperability scenarios . Use compiler settings /clr When common language runtime support is enabled , You can completely mix all local and managed C++ function . Other options can limit C++ Use of the pointer , So as to use C# and VB Write safe code like that .
(3)COM and COM+
Technically speaking ,COM and COM+ Not for .NET Technology , Because components based on them cannot assume that IL( But if the original COM Components are made of C++ Compiling , Then use hosting C++ To some extent, this can be done ). however ,COM+ Still an important tool , Because it contains some .NET Features not available . in addition ,COM Components can still be used –.NET Inherited COM Interoperability of , This allows managed code to call COM Components ,COM Components can also call managed code . In general , Write the new build as .NET Components , Mostly for convenience , Because it can make use of .NET Other benefits of base classes and managed code .
(4)Windows Runtime
边栏推荐
- 6 questions to ask when selecting a digital asset custodian
- Paper reproduction: expressive body capture
- Intercept file extension
- MySQL nested sorting: first sort and filter the latest data, and then customize the sorting of this list
- C语言试题三(语法选择题——含知识点详解)
- Visual (Single) Object Tracking -- SiamRPN
- KD-Tree and LSH
- 截取文件扩展名
- 华为设备配置本地虚拟专用网互访
- Solving graph problems with union search set
猜你喜欢

Apply the intelligent OCR identification technology of Shenzhen Yanchang technology to break through the bottleneck of medical bill identification at one stroke. Efficient claim settlement is not a dr

Tightly coupled laser vision inertial navigation slam system: paper notes_ S2D. 66_ ICRA_ 2021_ LVI-SAM

Differences between the four MQ

Paper reproduction: pare

AAAI2022-ShiftVIT: When Shift Operation Meets Vision Transformer

Tianchi - student test score forecast

博途仿真时出现“没有针对此地址组态任何硬件,无法进行修改”解决办法

Yolov5 training personal data set summary

Simple linear regression of sklearn series

Huawei equipment is configured to access the virtual private network through GRE
随机推荐
Real time update of excellent team papers
Paper reproduction: pare
Huawei equipment is configured to access the virtual private network through GRE tunnel
Zed2 running vins-mono preliminary test
一大厂95后程序员对部门领导不满,删库跑路被判刑
IOU series (IOU, giou, Diou, CIO)
Restoration of binary tree -- number restoration
Huawei equipment is configured with bgp/mpls IP virtual private network address space overlap
Win10+manjaro dual system installation
Lianrui electronics made an appointment with you with SIFA to see two network cards in the industry's leading industrial automation field first
Using keras to build the basic model yingtailing flower
Unzip Imagenet after downloading
New library goes online | cnopendata immovable cultural relic data
新库上线 | CnOpenData不可移动文物数据
go MPG
点击图标不灵敏咋整?
Take stock of the AI black technologies in the Beijing Winter Olympic Games, and Shenzhen Yancheng Technology
Learning summary 01- machine learning
Sealem Finance打造Web3去中心化金融平台基础设施
[entry level basics] node basic knowledge summary