Organizing Code with Partial Classes

You can split the definition of a class across multiple parts using the partial classes feature. You do not actually create different classes; you create one class implemented within multiple parts, typically across multiple files. This feature was first introduced in Visual Basic 2005 for separating Visual Studio’s auto-generated code from developer’s code, but it is useful in various scenarios. To see a practical implementation of partial classes, create a new Windows Forms project. Then click the Show All Files button in Solution Explorer, expand the Form1.vb item, and double-click the Form1.designer.vb file. Inside this file you can find the definition of the Form1 class, as shown in Listing 7.2.

LISTING ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.