Partial classes in VB.NET

In this article,we will discuss about Partial keyword.
  • 4805

Partial Classes

Partial classes mean that your class definition can be split into multiple physical files.

Logically, partial classes do not make any difference to the compiler. During compile time,

It simply groups all the various partial classes and treats them as a single entity.


There are several situations when splitting a class definition is desirable:

  • When working on large projects, spreading a class over separate files allows multiple
    programmers to work on it simultaneously.


  • When working with automatically generated source, code can be added to the class
    without having to recreate the source file.Visual Studio uses this approach when creating
    Windows Forms, Web Service wrapper code, and so on. You can create
    code that uses these classes without having to edit the file created by Visual Studio.

  • Coding for partial Class
     Public Partial Module Employee
     Public Sub show()
     End Sub

     End Module
     Public Partial Module
     Public Sub Display()
     End Sub
     End Module
     Public Shared Sub Main()
     Dim e1 As New employee()
     End Sub
     End Module


© 2020 DotNetHeaven. All rights reserved.