Partial Methods

Since Visual Basic 2008 and the .NET Framework 3.5, you can take advantage of another interesting feature that has been included in Visual Basic 2010: partial methods. Basically this feature has been mainly introduced in LINQ to ADO.NET, but it can be used in different scenarios for other language features. The concept behind partial methods is the same as partial classes: Methods implementations can be split across multiple parts. Partial methods have three particular characteristics: They must be Private methods, they cannot return values (that is, only Sub methods are allowed), and their bodies must be empty in the class in which methods are defined. Consider the following code, in which a class named Contact is split across ...

Get Visual Basic® 2010 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.