Thursday, November 18, 2010

Partial Class & Partial Method

It is possible to split the definition of a class or a struct, an interface or a method over two or more source files. Each source file contains a section of the type or method definition, and all parts are combined when the application is compiled.

e.g.
File:f1.vb
Public Interface I1
    Sub setMsg()
    Function getMsg() As String
End Interface

File:f2.vb
Partial Public Class C1
Implements I1

End Class

File:f3.vb
Partial Class C1

Partial Private Sub myTestFunc()
End Sub

End Class

File:f4.vb
Partial Public Class C1
Public Sub setMsg() Implements I1.setMsg
------------
-------------
End Sub
End Class

File:f5.vb
Partial Public Class C1

Public Function getMsg() As String Implements I1.getMsg
------------
-------------
End Function
End Class


File:f6.vb
Public Class C1
Private Sub myTestFunc()
------------
-------------
End Sub

End Class

reference:
http://www.4guysfromrolla.com/articles/071509-1.aspx