我有一个System.Version
个对象列表,
我需要获得列表中最好的版本以及大于指定版本的版本
Dim versions As New List(Of Version)
versions = LoadVersions()
' Get the greatest version object
Dim greatestVersion = versions.Greatest() '???
' Get version objects greater than the specified one
Dim ver = New Version("2.0.1.0")
Dim greaterVersions As List(Of Version) = version.GreaterThan(ver) '???
这样做的好方法是什么?
答案 0 :(得分:5)
最伟大的版本:
Dim greatestVersion = versions.Max()
大于所选版本:
Dim greaterVersions = versions.Where(Function (x) x > ver)
答案 1 :(得分:1)
这就是我要解决的问题,后来我改进了@Konrad建议:
'Greatest version
Dim maxver = versions.Max(Of Version)(Function(ver As Version) ver)
'Greater versions
Dim currentVersion As New Version("2.0.1.0")
Dim geaterVers = versions.Where(Function(ver As Version) ver > currentVersion)