How to Use Partial Classes in Visual Studio 2005
Introduction
The partial keyword was introduced in version 2.0 of the .NET framework. Very simply, the partial keyword permits you to split the definition of a single class, structure, or interface into more than one file. This means that if you’re working on large projects, multiple developers can work on multiple files, all containing parts of the same class. The partial keyword also means that it’s possible to split generated code into two parts: the part that’s generated, and another part that provides a convenient location for you and me to add customizations.
You’ll find the partial keyword used in Windows Forms classes to split the part that’s managed by the designer and the part where you add your code into two separate files. Strongly typed datasets use the partial keyword, permitting you to separate generated code and custom code in case you have to regenerate the typed dataset at a later time. Partial classes are also used in XML web services in .NET 2.0.
After you read the rules for using the partial keyword, see if you can come up with some new uses for partial classes.