Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.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中列表列表中所有[x]索引的最大值_C#_.net_Linq_List_Max - Fatal编程技术网

C# 获取C中列表列表中所有[x]索引的最大值

C# 获取C中列表列表中所有[x]索引的最大值,c#,.net,linq,list,max,C#,.net,Linq,List,Max,如果我在C项目中有一个List对象,我如何获得该对象中每个List中所有[x]索引的最大值 为了澄清我的想法,如果我有目标: List<List<double>> myList = ...... 所以,我需要得到值15,因为它是它们的最大值 谢谢, 当做 Aya使用以下最大索引值 List<List<double>> list = ... var maxIndex = list.Max( innerList => innerList.Cou

如果我在C项目中有一个List对象,我如何获得该对象中每个List中所有[x]索引的最大值

为了澄清我的想法,如果我有目标:

List<List<double>> myList = ......
所以,我需要得到值15,因为它是它们的最大值

谢谢, 当做
Aya

使用以下最大索引值

List<List<double>> list = ...
var maxIndex = list.Max( innerList => innerList.Count - 1); // Gets the Maximum index value.
另见

按评论编辑

我需要每个列表中特定索引中的最大值

一个未优化的解决方案是使用以下查询

var index = 10;
var maxAtIndex10 = list.Max ( innerList => innerList[index]);
下面的查询是查找所有索引的最大值

var maxIndex = list.Max( innerList => innerList.Count);
var listMaxAtAllIndexes = Enumerable.Range(0,maxIndex).Select ( index => list.Max(innerList => index < innerList.Count ? innerList[index] : 0));

你所说的所有[x]索引的完整性到底是什么意思?你的问题不清楚。谢谢你的回复,但我不想知道每个列表的最大值。相反,我需要每个列表中特定索引中的最大值。
var index = 10;
var maxAtIndex10 = list.Max ( innerList => innerList[index]);
var maxIndex = list.Max( innerList => innerList.Count);
var listMaxAtAllIndexes = Enumerable.Range(0,maxIndex).Select ( index => list.Max(innerList => index < innerList.Count ? innerList[index] : 0));