1. structure
the structure and class are almost the same, when defining, you only need to class written as struct . Defining a function for a structure is the same as defining a function for a class.
When should I use the structure? In some cases, we only need a small data structure. If classes are used, the performance will be compromised, and the structure is suitable.
Note that the structure is a value type, while the class is a reference type. The structure does not support inheritance. during compilation, the compiler always provides a constructor without parameters; constructors without parameters cannot be defined in the structure.
2. Classification
sometimes, multiple people may access the same class. We may put the same class, interface, or structure in different files, you only need to interface Add partial keyword.
For example, the following two different source codes are located in different files. during compilation, the system automatically createsTestoneClass, merge the methods in the two files.
Partial class testone {
Public void methodone (){}
}
Partial class testone {
Public void methodtwo (){}
}
III,ObjectClass.
all . net classes are derived from system. object .
Since all are derived fromSystem. ObjectIn this way, we can directly use some specific methods. For exampleTostring ()It is a convenient way to obtain the string representation of an object.