Understand the CLR principle in .NET
Author: yarshray saga join (To reprint please include the author, thank you!)
* Part of our hands - Assembly (assembly)
1. About assembly
* Let us run in the same system - CTS (General Type System)
1. Let's talk about System.Object --- Roots of all Net
All classes in the CTS are derived from the System.Object object. It provides basic operations as follows:
Equals
Overloaded. Determine if the two Object instances are equal.
Gethashcode
Used as a specific type of hash function, suitable for use in a hash algorithm and data structure (such as a hash table).
Gettype
Get the current instance of TYPE.
Referenceequals
Determine if the specified Object instance is the same instance.
Tostring
Returns the String that represents the current Object.
In addition, CTS also defines a set of across language objects. Most compilers provide an alias for these objects. Here is C # as an example:
Object, int, String, Sbyte, Byte, Short, Long, Float, Char, Double, Bool Decimal.
The following two topics, because I have answers too much in the forum, if you are interested in the 9CBS C # version to search, you will find a lot, basically I have participated. So here I only put it.
2. Value type and reference type
Reference Type Reference:
MS-Help: //ms.vscc/ms.msdnvs.2052/csref/html/vcrefreferencetypes.htm
Value type reference:
MS-help: //ms.vscc/ms.msdnvs.2052/csref/html/vcrefvalueTypes.htm
3. Don't confuse the boxing and unboxing and type conversion
reference:
MS-help: //ms.vscc/ms.msdnvs.2052/csref/html/vclrfboxingunboxingpg.htm
* Products after the universe --- metadata (metadata)
1. The relationship between Metadata and IDL:
Metadata describes some of the information of the data type in the code (Common Language Runtime) that needs to be learned when the code is executed. Metadata allows .NET application code to provide self-description features, providing type security, which requires additional type libraries or interface definition languages (Idl). If you have been doing COM before you have done it, you must get Metadata in your COM must be accessed from the registry.
Metadata is information about PE in the component object model, and the metadata is through non-standard type library communication. In .NET, these data is included in the target file format, including PEs matching the target file format and Some determination guidelines; the information on which the information is contained, the version, the exterior of the language is used as a reference annotation, and the internal form is also very transparent, clearly clarifies the method of use, referenced, and the like. The General Computer Language (CLR) is dedicated to using metadata. Security is managed by a public key in the header file of the PE. CLR can know some information about classes and modules, if necessary, even the structure of the structure can be mastered. The components of the CLR in the loader are also located in the metadata assembly, local or networks can be located. Just-in-Time (JIT) also uses metadata to convert the media language (IL) into executable code. Some other procedures are also beneficial when using metadata. Here is a very common example of using the Word document under Windows 2000. If this document file has completed content, author, title, or other metadata, his text content is displayed like a tool comment, when the user waves above the top file icon. You can use iLDasm.exe's feature to see metadata in the PE library. 2. Starting from Attribute:
The generation of metadata is from Attribute, and is different from COM. The properties in the NET can be defined by themselves. all. Attribute in NET is derived from System.attribute. Then we can create your own description. Manage, as follows;
Attributeusage (AttributeTargets.all)] Public Class Yarshrayattribute: System.attribute {Private String Name; Private Int Age; Private Bool Sex;
Public Developerattribute (String Name, Int Age, Bool SEX) {this.name = name; this.age = age; this.sex = sex;}
Public virtual string name {get {return name;}}
Public Virtual Int Age {get {return agn;}}
public virtual bool Sex {get {return sex;} set {sex = value;}}} [YarshrayAttribute ( "yarshray", "21", Sex = true;] public class YarshrayTest {public Yarshray () {// nothing just make a test}}
Let's use the above metadata:
Using system.rection; usingspace yarshrayapp {public class yarshrayconsoleapp {
Public static void
Main