这是只有蜂群思维才能提供帮助的时代之一 - 再多的 Google 也无法提供帮助!
我有一个结构数组:
Structure stCar
Dim Name As String
Dim MPH As Integer
Sub New(ByVal _Name As String, ByVal _MPH As Integer)
Name = _Name
MPH = _MPH
End Sub
End Structure
如何根据结构的一个变量/属性对数组进行排序?
Dim cars() as stCar = {new stCar("ford",10), new stCar("honda",50)}
cars.sort("MPH") // how do I do this?
最佳答案
假设该结构有一个名为 MPH 的属性:
cars = cars.OrderBy(Function(c) c.MPH)
注意:上面的代码是从以下 C# 代码自动转换的(以防包含错误):
cars = cars.OrderBy(c => c.MPH);
关于vb.net - 对 .NET 中的结构数组进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1751768/