Under the same namespace, you can define only one class of the same class name, for example, there can be only one person class under a namespace.
Partial classes: Understanding that each part is just part of the constituent class, is actually a class, all members are shared, that is, variables defined in a partial class,
In another part of the class can be used, then the variables defined in a partial class, in other parts of the class can not be repeated definition, it is understood to put a class of members, separate into different classes.
Through the case demonstration:
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespacePartial Classes8 {9 class ProgramTen { One Static voidMain (string[] args) A { - - // the - - } - } + - + //only one person class can be defined under a namespace, and the Person class section class may be written A //Partial : A class is made up of some classes, all of which are common and are actually a class at Public Partial class Person - { - Private stringname; - - //void Test ()//will be an error, in another part of the class has - //{ in - //} to } + - Public Partial class Person the { * //all members are shared, including private members $ //private string name;Panax Notoginseng - voidTest () the { + //members of other parts of the class can be directly used A Console.WriteLine (name); the } + } - $ Public Partial class Person $ { - //You can define multiple partial classes - } the - Wuyi}
C#_ Basics _ Partial class partial (18)