码迷,mamicode.com
首页 > 编程语言 > 详细

VB.NET实现泛型List<T>排序的方法

时间:2016-05-18 09:08:03      阅读:2132      评论:0      收藏:0      [点我收藏+]

标签:

类型定义
Public Structure RingRecord
    Dim recordTime As DateTime
    Dim footSteps As String
    Dim sportMinutes As String
    Dim distance As String
    Dim calorie As String
End Structure

’写比较子
Private Shared Function sortRingRecord(ByVal xRingRecord As RingRecord, ByVal yRingRecord As RingRecord) As Integer
    If (xRingRecord.recordTime > yRingRecord.recordTime) Then
        Return -1
    ElseIf xRingRecord.recordTime = yRingRecord.recordTime Then
        Return 0
    Else
        Return 1
    End If
 End Function

排序
Dim lstRingRecord As List(Of RingRecord)
lstRingRecord = JsonConvert.DeserializeObject(Of List(Of RingRecord))(strRecordData) 此处list的元素由Json取得,实际使用依实际情况而定
lstRingRecord.Sort(AddressOf sortRingRecord)

 

VB.NET实现泛型List<T>排序的方法

标签:

原文地址:http://www.cnblogs.com/brucechang/p/5503943.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!