【发布时间】:2017-12-01 15:45:13
【问题描述】:
以这些类为例:
Public Class ClsA
Public Property l As Integer
Public Property w As Integer
Public Property h As Integer
End Class
Public Class ClsB
Private Property myClsA As ClsA
Public Property l As Integer
Get
Return myClsA.l
End Get
Set(value As Integer)
myClsA.l = value
End Set
End Property
Public Property w As Integer
Get
Return myClsA.w
End Get
Set(value As Integer)
myClsA.w = value
End Set
End Property
Public Property h As Integer
Get
Return myClsA.h
End Get
Set(value As Integer)
myClsA.h = value
End Set
End Property
Public Property someOtherProperty As Integer
End Class
这意味着不是像这样访问“l”:
myClsB.myClsA.l
我可以的
myClsB.l
这是我想要的,但我必须单独通过每个属性,因此随着 ClsA 的公共属性数量的增加,它变得越工作。
有什么方法可以传递包含对象的所有属性(就好像它们是容器对象自己的属性一样)而不必单独处理每个属性?
【问题讨论】:
-
目前没有,没有。即使对 DynamicObject 实现使用
dynamic之类的操作也比编写包装器要困难得多。
标签: .net class properties