ARTICLE

Partial classes in VB.NET

Posted by Munesh Sharma Articles | VB.NET Articles March 15, 2011
In this article,we will discuss about Partial keyword.
 
Reader Level:

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.

 partial-class.gif

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:

          partialclass-2.gif
     
     
  • Login to add your contents and source code to this article
    share this article :
    post comment
     
    Nevron Diagram
    Become a Sponsor
    PREMIUM SPONSORS
    • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
      The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    Team Foundation Server Hosting
    Become a Sponsor