我想收到一个按'Product.Name‘排序的列表,按降序排列。
类似于下面的函数,它将列表按升序排序,只是反向排序,这是可能的吗?
var newList = list.OrderBy(x => x.Product.Name).ToList();
发布于 2010-10-13 23:22:39
当然:
var newList = list.OrderByDescending(x => x.Product.Name).ToList();
医生:OrderByDescending(IEnumerable, Func)。
对您的评论的回应:
var newList = list.OrderByDescending(x => x.Product.Name)
.ThenBy(x => x.Product.Price)
.ToList();
发布于 2010-10-13 23:22:46
是。使用OrderByDescending
而不是OrderBy
。
发布于 2010-10-13 23:23:43
list.OrderByDescending();
这对我很有效。
https://stackoverflow.com/questions/3925258
复制相似问题