我正在尝试将 mySubClass.vb 文件实现为另一个主类的嵌套子类。似乎这个Partial Class
想法是我需要的,但是当我尝试将 mySubClass.vb 作为另一个主类的嵌套子类拉入时,实现不起作用。
我直接使用此代码的原始实现,mySubClass
因此我知道该功能有效。我只想mySubClass
在clsMain
.
主班
Public Class clsMain
Public Property myIntProp as Integer
Public property myStrProp as String
'other properties
Partial Public Class MySubClass
'I want this functionality to be accessible via clsMain.MySubClass
'Just like any other property or function of clsMain
'Partial would keep things organized nicely
End Class
End Class
子类
我想用作 clsMain.MySubClass 的 class.vb。文件:MySubClass.vb
Partial Public Class MySubClass
Inherits BaseCollection
Private Class MySubSubClass '(Used for custom properties and functions)
'More properties and Functions
End Class
End Sub
Public Class BaseCollection 'functionality of MySubClass
Public Function MyFunction1()
'Return Data
End Function
End Class
如何使用主类
Public Class UsageClass
Private myMainDataStructure as new clsMain
Private Sub GetSubClassList()
dim MyData as ArrayList = myMainDataStructure.MySubClass.MyFunction1()
'^^^ error on this line: MyFunction1() is not a member of project.clsMain.MySubClass^^^
End Sub
End Class