2

我有一个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) '???

什么是这样做的好方法?

4

2 回答 2

5

最伟大的版本:

Dim greatestVersion = versions.Max()

大于所选版本:

Dim greaterVersions = versions.Where(Function (x) x > ver)

阅读MSDN LINQ 参考

于 2013-04-17T18:05:20.233 回答
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)
于 2013-04-17T18:42:09.277 回答