First, the structure
Structure and class are almost the same, in the definition of the time only to write class as struct. Defining functions for structs is exactly the same as defining functions for a class.
When do you use the structure? At some point, we just need a small data structure. If the use of class words performance is a loss, and the use of the structure is more appropriate.
Note that structs are value types, and classes are reference types; structs do not support inheritance; At compile time, the compiler always provides an parameterless constructor, and no parameterless constructors are allowed in the structure.
Ii. part of the class
Sometimes, there may be more than one person accessing the same class, we may put the same class, interface or structure in different files, only need to precede the class interface structure with the partial keyword.
For example, the following two different source code is located in different files, when compiling, the system will automatically create a Testone class, merging two files in the method.
partial class testOne{
public void MethodOne(){}
}
partial class testOne{
public void MethodTwo(){}
}
Three, object class.
All of them. NET classes are derived from System.Object.
Since all derive from System.Object, some of its specific methods can be used directly. For example, the most common simple ToString () method is a convenient way to get the string representation of an object.