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);