我敢于做一些事情,这应当简单明了,但与林克和瓦布作斗争。 我下面谈一下,在这里,我把收集工作按适当分类,然后想要获得我的团体的财产。 问题 我有匿名打字。 由于选择严格,我必须给出一个明确的类型,但我可以确定哪一种类型。 The following don t volume because t.HeadAccount 关键数值(因为t有某种物体)。 因此,我要么需要做一些投放,要么我的林克挑选人错了,
public class TempObject
public HeadKey as string
Public SubKey as string
Public SomeValue as decimal
end class
public class GroupTest
public sub RunTest
dim collection new List(of TempObject) = GetTestCollection()
Dim groupedValues As IEnumerable = From n In collection _
Group By key = n.HeadKey Into Group Select HeadKeyValue = key, SubValues = Group
for each t as object in groupedValues
debug.print(t.HeadKeyValue)
next
End sub
private function GetTestCollection() as List(of TempObject)
dim result as new list(of tempobject)
Dim x As New tempObject
x.HeadAccountNumber = "A"
x.SubAccountNumber = "B"
x.Value = 500
result.Add(x)
x = New tempObject
x.HeadAccountNumber = "A"
x.SubAccountNumber = "C"
x.Value = 600
result.Add(x)
x = New tempObject
x.HeadAccountNumber = "B"
x.SubAccountNumber = "D"
x.Value = 100
result.add(x)
return result
end function
End class