【发布时间】:2018-11-01 16:12:24
【问题描述】:
PropertyPolicy 是一个定义多个字段/实体的集合的类。有时需要两个单独的函数来构建集合。 (LoadEstateAIN 和 LoadAIN)。我需要结合两个类的结果,但尝试过 concat 但得到一个强制转换异常。这里有什么用?
Public Class PropertyPolicy
Private agentfield As Entity
Private aininsuredfield() As Entity
Private billinginfofield As BillingInfo
Private cancellationdatefield As Date
Private claimsfield() As Claims
Public Property Agent As Entity
Get
Return Me.agentfield
End Get
Set(ByVal value As Entity)
Me.agentfield = value
End Set
End Property
Public Property AINInsured() As Entity()
Get
Return Me.aininsuredfield
End Get
Set(ByVal value As Entity())
Me.aininsuredfield = value
End Set
End Property
Public Property BillingInfo As BillingInfo
Get
Return Me.billinginfofield
End Get
Set(ByVal value As BillingInfo)
Me.billinginfofield = value
End Set
End Property
Public Property CancellationDate As Date
Get
Return Me.cancellationdatefield
End Get
Set(ByVal value As Date)
Me.cancellationdatefield = value
End Set
End Property
Public Property Claims() As Claims()
Get
Return Me.claimsfield
End Get
Set(ByVal value As Claims())
Me.claimsfield = value
End Set
End Property
End Class
Dim propTemp1 As New PropertyPolicy
Dim propTemp2 As New PropertyPolicy
Dim propTempComb As New PropertyPolicy
propTemp1.AINInsured = LoadEstateAIN(policyid, asofDate, lob, NINclientid, estatecompany)
propTemp2.AINInsured = LoadAIN(policyid, asofDate, lob, NINclientid, estatecompany)
propTempComb.AINInsured = propTemp1.AINInsured.Concat(propTemp2.AINInsured)
【问题讨论】:
-
您希望 Concat 做什么?你在看joining two arrays together吗?
-
我希望它将两个类结果(来自两个单独的函数调用)结合在一起,形成一个新的单类结果。然后将结果序列化为 xml 并发送回另一个进程。我只是不确定使用什么来将同一类结构的两个实例基本合并为一个。也许这是不可能的,我只需要在处理第一个函数或其他东西的过程中调用第二个函数,但如果可能的话,我想加入结果。
-
“将两个班级的成绩结合在一起”是什么意思?例如,如果您在两个类中都有一个整数。比方说,3 和 5。结果应该是 8 吗? 35?别的东西?日期呢。
-
在您的示例中,您尝试将属性连接在一起,它们是数组 - 而不是类实例本身。如果要加入实例,可以在类中编写一个方法,该方法采用类的实例并显式连接所有数组,并相应地处理非数组属性(例如,如何加入两个代理?)...如果这就是你想要做的......
-
在这种情况下,一切都被定义为 PropertyPolicy 类结构。我正在调用两个单独的函数,它们返回此类的一个实例,并且只想组合结果,因此如果第一个函数返回一个由 2 个 aininsuredfield () 组成的数组,而第二个函数返回 1,则一个新的 propTempComb.AINInsured 组合实例( ) 将拥有所有 3。没有添加或任何东西,只有被保险实体的 3 次单独出现。我会尝试 .toarray()
标签: vb.net function class exception concat