我正在编写一个库,我希望Main
类的属性返回类,以便可以通过链接调用类方法。
Main main = new Main()
main.Foo.Bar()
我还会在Main
上有属性来返回对象实例。
Main main = new Main()
main.Foo("name").Baz()
这将允许我将所有相关功能保留在单个类中,但只公开每个上下文中可用的方法。反正有吗?
答案 0 :(得分:0)
这样的东西?
示例用法:
Dim main As New Main
main.Foo.Bar.SomeMethod()
Public Class Main
Private m_Foo As Foo = New Foo()
Public Property Foo As Foo
Get
Return m_Foo
End Get
Set(value As Foo)
m_Foo = value
End Set
End Property
End Class
Public Class Foo
Private m_Bar As Bar = New Bar
Public ReadOnly Property Bar
Get
Return m_Bar
End Get
End Property
End Class
Public Class Bar
Public Sub SomeMethod()
End Sub
End Class