Sort an array of structures in .NET

前端 未结 7 1221
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 07:02

This is one of those times when only the hive mind can help - no amount of Google-fu can!

I have an array of structures:

Structure stCar 
    Dim Nam         


        
7条回答
  •  萌比男神i
    2020-12-16 07:15

    In VB.Net of VS2015 there is another method of sorting:

    cars.Sort(New Comparison(Of stCar)(Function(x, y) 'x and y are of type of stCar
                                                                 If x.MPH > y.MPH Then
                                                                     Return 1 ' Return Value>0 means x>y
                                                                 End If
                                                                 If x.MPH < y.MPH Then
                                                                     Return -1 ' Return Value<0 means x

提交回复
热议问题