
The following example shows that you can also develop partial structs and interfaces. Keep the console window open in debug mode.Ĭonsole.WriteLine("Press any key to exit.")

The following are merged from all the partial-type definitions:įor example, consider the following declarations: partial class Earth : Planet, IRotate ", x, y) They are equivalent to the following declarations: For example, consider the following declarations: class ContainerĪt compile time, attributes of partial-type definitions are merged. The following example shows that nested types can be partial, even if the type they are nested within is not partial itself. The partial modifier is not available on delegate or enumeration declarations. The final type is the combination of all the parts at compile time. Any class, struct, or interface members declared in a partial definition are available to all the other parts. Parts can specify different base interfaces, and the final type implements all the interfaces listed by all the partial declarations. If any part declares a base type, then the whole type inherits that class.Īll the parts that specify a base class must agree, but parts that omit a base class still inherit the base type. If any part is declared sealed, then the whole type is considered sealed. If any part is declared abstract, then the whole type is considered abstract.

All the parts must have the same accessibility, such as public, private, and so on. All the parts must be available at compile time to form the final type. All the parts must use the partial keyword. The partial keyword indicates that other parts of the class, struct, or interface can be defined in the namespace. To split a class definition, use the partial keyword modifier, as shown here: public partial class Employee

When using source generators to generate additional functionality in a class.
#Coords meaning code#
You can create code that uses these classes without having to modify the file created by Visual Studio.
#Coords meaning windows#
Visual Studio uses this approach when it creates Windows Forms, Web service wrapper code, and so on.
