Partial classes in VB.NET
In this article,we will discuss about Partial keyword.
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()
Console.WriteLine("MCN")
End Sub
End Module
Public Partial Module employee
Public Sub Display()
Console.WriteLine("soluation")
End Sub
End Module
Module output
Public Shared Sub Main()
Dim e1 As New employee()
e1.Display()
e1.show()
End Sub
End Module
Output: