All types are derived from System.Object, and the ' runtime ' requires that each type be from system. The object class derives, that is, the following two type definitions are exactly the same:
Implicitly derived words objectclass employee{do something ...} An explicit derivation of the word Object class employee:system.object{do something ...}
Since all types ultimately derive from System.Object, each object of each type guarantees a basic set of methods, and System.Object provides a common instance approach:
1, Equals: Returns True if two objects have the same value.
2, GetHashCode: Returns the hash of the value of the object.
3. ToString: The full name of the default return type (This.gettype (). FullName).
4. GetType: Returns an instance of type derived from one of the types that indicates what type of object is called GetType. The returned type object can mate with the reflection class to get metadata information about the type of the object.
The CLR requires that all objects be created with the new keyword, and the following code shows how to create an Employee object:
Employee E = new Employee ("Constructorparameter");
Here's what the new operator does
1. The calculation type and all of its base types (until System.Object, although he does not define his own instance fields) require a number of additional members for each object on the heap, including the type Object Poniter and Sync Block index. The CLR takes advantage of these members to manage objects, and the extra member's bytes are counted in the size of the member.
2. Allocate the number of bytes required by the class from the managed heap to classify the object's memory and allocate all bytes to zero.
3. Initialize the object's "type Object pointer" and "Synchronize index block" members.
4. Invokes the instance constructor of the type, passing the argument specified in the new call.
New returns a reference (pointer) to the new object after all of these operations have been performed.
Note: There is no delete operator for the new operator: In other words, there is no way to explicitly release the memory allocated to the object, and the CLR uses a garbage collection mechanism (GC) to automatically detect that an object is no longer being used and accessed, and frees the object's memory.
NET Fundamentals (1): Type basics