我正在使用该应用程序中的vb.net windows8移动应用程序我在列表中保存项目帮助我根据该列表中的单个项目按顺序放置此列表。
代码:
'Job Custom Event Details...............
Dim JobEventAllDetails As New List(Of EventDetails)
JobEventAllDetails = JobEventDetails.EventDetailsList.ToList()
列出订单:
(New System.Collections.Generic.Mscorlib_CollectionDebugView(Of Agility_Alerts.TrackingServiceReference.EventDetails)(JobEventAllDetails)).Items(0).Seq 0
(New System.Collections.Generic.Mscorlib_CollectionDebugView(Of Agility_Alerts.TrackingServiceReference.EventDetails)(JobEventAllDetails)).Items(2).Seq 300
(New System.Collections.Generic.Mscorlib_CollectionDebugView(Of Agility_Alerts.TrackingServiceReference.EventDetails)(JobEventAllDetails)).Items(1).Seq 200
答案 0 :(得分:1)
在VB单元测试项目中试试这个
Imports System.Text
Imports Microsoft.VisualStudio.TestTools.UnitTesting
<TestClass()> Public Class UnitTest1
<TestMethod()> Public Sub TestMethod1()
Dim eventDetailsList As New List(Of EventDetails) From { _
New EventDetails With {.Seq = 0, .SomeData = ""}, _
New EventDetails With {.Seq = 300, .SomeData = ""}, _
New EventDetails With {.Seq = 200, .SomeData = ""}}
Dim JobeventDetails As New JobEventDetailsList With {.EventDetailsList = eventdetailslist}
Dim JobEventAllDetails = JobeventDetails.EventDetailsList.OrderBy(Function(j) j.Seq).ToList
For Each job In JobEventAllDetails
Console.WriteLine(job.Seq)
Next
End Sub
End Class
Class EventDetails
Public Property Seq As Integer
Public SomeData As String
End Class
Class JobEventDetailsList
Public EventDetailsList As List(Of EventDetails)
End Class
答案 1 :(得分:0)
如果您的意思是按属性对列表进行排序......您可以使用OrderBy函数
Dim list2 = list.OrderBy(Function(k) k.field2)