重要信息的人有类似的查询与性能的嵌套类 - 如何使用第一窝的性能在`Set`值第二
答案很简单,你在看这个不能 - 从Plutonix答案如下解释花费1/2的一天谷歌搜索这之后为什么因此它被标记为答案
原始的问题
交白卷!
我有下面的类:
Public Class TestClass
Dim _nestedProperty As New NestedProperty()
Private Shared Item As String
Public Property Nest1a() As NestedProperty
Get
Return _nestedProperty
End Get
Set(Value As NestedProperty)
End Set
End Property
Public Property Nest1b() As NestedProperty
Get
Return _nestedProperty
End Get
Set(Value As NestedProperty)
End Set
End Property
Public Class NestedClass
Property Nest2a As String
Get
Return sub1()
End Get
Set(value As String)
'the first value in sub 2 needs to be the name of the Nest1 property
sub2([how do i get this value],value)
End Set
End Property
Property Nest2b As String
Get
Return sub1()
End Get
Set(value As String)
'the first value in sub 2 needs to be the name of the Nest1 property
sub2([how do i get this value],value)
End Set
End Property
End Class
Shared Function sub1()
End Function
Shared Sub sub2(Nest1 As String, Value As String)
End Sub
End Class
在现实中有第一窝许多属性,我想知道哪一个是“呼”第二套件。
即如果我使用TestClass.Nest1a.Nest2a = "abc"
,当从Nest2a
的Set
我需要"Nest1a"
代替[how do i get this value]
传递主叫Sub2
。
我尝试在第一个巢的Set
中设置'Item'对象,但它不起作用!
从主要形式,我对下面的代码调用这个类:
Dim TC As New TestClass
TC.Nest1.Nest2a = "xyz"
'lots more code
TC.Nest1.Nest2b = "abc"
我不想每次使用它的时候创建的TestClass
一个新的实例!
任何人都可以提出解决方案吗?
我不太明白这个问题。根据上面的示例代码(第二代码块),您希望取代'[我如何获取此值]'? – har07
@ har07 - 查看更新的问题。 – OSKM
'[我怎么得到这个值]'有几次。对于TestClass.Sub2,它只是'TestClass.Sub2',但作为一个子没有'get'的值。有关实际属性,请参见下文。 'TC.Nest1.Nest2a =“xyz”'是无效的,因为它们不是嵌套的道具 - Nest2a属于不同的类。 – Plutonix