Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.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#,以上代码适用于单个产品。我有一份产品清单,上面有各种产品的价格和税。我需要一种方法,以降序排序,相对于总价格,这应该考虑到总价格,这将是价格+税。以下产品列表应具有第一个元素的最高价格+税的顺序 Product : { price :10, tax:2 } 使用Linq OrderByDescending首先获取最高值 Products=Products.orderbydowningx=>x.price+x.tax.ToList 到目前为止你有没有尝试过什么,或者你要求我们做你的

以上代码适用于单个产品。我有一份产品清单,上面有各种产品的价格和税。我需要一种方法,以降序排序,相对于总价格,这应该考虑到总价格,这将是价格+税。以下产品列表应具有第一个元素的最高价格+税的顺序

Product : {
   price :10,
   tax:2
} 
使用Linq OrderByDescending首先获取最高值


Products=Products.orderbydowningx=>x.price+x.tax.ToList

到目前为止你有没有尝试过什么,或者你要求我们做你的工作?有几十个问题,比如如何根据属性对列表进行排序。
Products [
    Product : {
       price :15,
       tax:2
   }  ,
   Product : {
        price :1,
       tax:32
   }  
 ,
   Product : {
        price :2,
       tax:2
   }  




]