Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下数组:
a) 3,7,2 // 长 x 宽 x 高
b) 6,3,9
c) 5,9,3
我需要执行搜索以创建一个新列表,该列表由每个变量的长度和宽度之间的最大值编译而成。即此问题的正确C#代码将返回以下列表:
一)7
b) 6
c) 9
有什么建议么?
IEnumerable<int> maxes = dimensions.Select(dim => Math.Max(dim[0], dim[1]));
或者
IEnumerable<int> maxes = dimensions.Select(dim => dim.Take(2).Max());