我有一个类ClassA,我在其中创建另一个类ClassB的对象(classB_obj)。 如何使用此classB_obj访问/设置ClassB内的结构的值? 我不熟悉vb.net中的语法。我想要做的就是这个
Public ClassA
Public Sub SomeSub
Dim ClassB_obj As New ClassB()
Dim classB_struct As ClassB.sampleStruct 'The error is **Type ClassB.sampleStruct not defined**
End Sub
End ClassA
Public ClassB
Private Structure Struct
Dim xy As String
Dim yz As String
End Structure
Dim sampleStruct As Struct
'Member functions here
End ClassB
错误是类型ClassB.sampleStruct未定义
谁能告诉我哪里出错了?这里有新手到vb.net并且不熟悉语法。 非常感谢
答案 0 :(得分:0)
您需要将允许在课堂外访问的Class B
成员声明为Public
Public ClassB
Public Structure Struct
Dim xy As String
Dim yz As String
End Structure
'Public sampleStruct As Struct
End ClassB
Public ClassA
Public Sub SomeSub
'Dim ClassB_obj As New ClassB()
Dim classb_struct As ClassB.Struct
End Sub
End ClassA
答案 1 :(得分:0)
你的结构是私有的,你试过把它公之于众吗?