Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#从对象列表中的字段中获取最大的数字_C# - Fatal编程技术网

C#从对象列表中的字段中获取最大的数字

C#从对象列表中的字段中获取最大的数字,c#,C#,我有一个结构如下的列表: public class Amendment{ public string name public string groupnumber public string edition public string destination } 数据如下: var amendmentOne = new Amendment{ name = "Apple", groupnumber = "A12345", edition =

我有一个结构如下的列表:

public class Amendment{
    public string name
    public string groupnumber
    public string edition
    public string destination
}
数据如下:

var amendmentOne = new Amendment{
    name = "Apple",
    groupnumber = "A12345",
    edition = "A55600E01"
    phonenumber = "2232132123"
}
var amendmentTwo = new Amendment{
    name = "Apple",
    groupnumber = "AG2222",
    edition = "A55600E02"
    phonenumber = "2232132123"
}
var amendmentThree = new Amendment{
    name = "Apple",
    groupnumber = "AG55555",
    edition = "A55600E03"
    phonenumber = "2232132123"
}
当我循环浏览列表时,是否可能以某种方式从列表中获取版本号为A55600E03的列表项?除了最后几个字符外,版本号都是相同的,因为它们总是E[number]

应该尽可能简单

var result = List.Orderby(x => edition).Last();
示例

var list = new List<Amendment>{amendmentThree, amendmentOne, amendmentTwo};
var result = list.OrderBy(x => x.edition).Last();
Console.WriteLine(result.edition);
应该尽可能简单

var result = List.Orderby(x => edition).Last();
示例

var list = new List<Amendment>{amendmentThree, amendmentOne, amendmentTwo};
var result = list.OrderBy(x => x.edition).Last();
Console.WriteLine(result.edition);