Gets or sets a value indicating whether the type declaration is complete or partial.
Assembly: System (in System.dll)
You can build a class or structure implementation in one complete declaration, or spread the implementation across multiple declarations. Implementations are commonly supplied in one complete type declaration. In this case, set the type declaration property to false, which indicates that the type declaration represents all details for the class or structure implementation.
A partial type declaration makes it easier to build different portions of a class or structure implementation in different modules of your application. The partial type declarations can be stored in one source file, or spread across multiple source files that are eventually compiled together to form the combined type implementation.
The C# language supports partial type declarations of classes and structures through the partial keyword. Visual Basic supports partial type declarations of classes and structures with the Partial keyword. Not all code generators support partial type declarations, so you should test for this support by calling the Supports method with the flag PartialTypes.
Partial type declarations are supported for classes and structures. If you specify a partial type declaration for an enumeration or interface, the generated code produces compiler errors.
When supplying a class or structure implementation across multiple declarations, set the property to true for the initial declaration and all supplemental declarations. The initial declaration must fully specify the type signature, including access modifiers, inherited types, and implemented interfaces. The supplementary declarations do not need to re-specify the type signature. A compiler error typically results if you redefine the type signature in a supplementary declaration.
Visual Studio 2005 uses partial types to separate user-generated code from designer code. In Visual Basic Windows Application projects, the user code is placed in a partial class that is not qualified by the Partial keyword; the designer-provided code appears in the partial class that has the Partial keyword. In C#, both the user code and designer code appear in partial classes identified by the partial keyword.
This example demonstrates using a CodeTypeDeclaration to supply a class implementation across multiple declarations. The example builds the initial class declaration statement and sets the property to true.
CodeTypeDeclaration baseClass = new CodeTypeDeclaration("DocumentProperties"); baseClass.IsPartial = true; baseClass.IsClass = true; baseClass.Attributes = MemberAttributes.Public; baseClass.BaseTypes.Add(new CodeTypeReference(typeof(System.Object ))); // Add the DocumentProperties class to the namespace. sampleSpace.Types.Add(baseClass);
A different method in the example extends the class implementation. This method builds a new type declaration statement for the existing class and sets the property to true. The compiler combines the two partial type declarations together for the complete class implementation.
CodeTypeDeclaration baseClass = new CodeTypeDeclaration("DocumentProperties"); baseClass.IsPartial = true; baseClass.IsClass = true; baseClass.Attributes = MemberAttributes.Public; // Extend the DocumentProperties class in the unit namespace. docPropUnit.Namespaces.Types.Add(baseClass);
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.