Dela via


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:

namespace PC
{
    partial class A 
    {
        int num = 0;
        void MethodA() { }
        partial void MethodC();
    }
}

In File2.cs the declaration:

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

Remarks

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 Windows Forms Designer. A partial type may contain a partial method. For more information, see Partial Classes and Methods (C# Programming Guide).

C# Language Specification

For more information, see the following section in the C# Language Specification:

  • 10.2 Partial types

See Also

Concepts

C# Programming Guide

Reference

Modifiers (C# Reference)

Introduction to Generics (C# Programming Guide)

Other Resources

C# Reference