partial (Type)

partial (Type) (C# Reference)


Partial type definitions allow for the definition of a class, struct, or interface to be split into multiple files.

In File1.cs:

Fahrenheit fahr = new Fahrenheit(100.0f);
Console.Write("{0} Fahrenheit", fahr.Degrees);
Celsius c = (Celsius)fahr;

In File2.cs the declaration:

namespace PC
    partial class A
        void MethodB() { }
        partial void MethodC() { }

Splitting a class, struct or interface type over several files can be useful when you are working with large projects, or with automatically generated code such as that provided by the . A partial type may contain a partial method. For more information, see Partial Classes and Methods (C# Programming Guide).3c3d61f8-f36c-4d41-b9c3-398376fabb15

For more information, see the C# Language Specification. The language specification is the definitive source for C# syntax and usage.

© 2015 Microsoft