Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/337.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如何获取对象数组的属性并对其进行操作?_C#_Arrays_Object - Fatal编程技术网

C# C如何获取对象数组的属性并对其进行操作?

C# C如何获取对象数组的属性并对其进行操作?,c#,arrays,object,C#,Arrays,Object,我有一个对象卡阵列: 卡片[]手; 对象卡具有以下属性: 整数卡值 我需要获得卡[]手中的最大CardValue 在我缺乏知识的情况下,我想我能做的是用每张卡的所有卡值创建一个新的int[],但是有没有一种eaiser方法?使用LINQ Max扩展方法: var result = hand.Max(c => c.CardValue); 是的,LINQ有一种方法正好用于此目的: int maxValue = hand.Max(card => card.CardValue); 你为此

我有一个对象卡阵列: 卡片[]手; 对象卡具有以下属性: 整数卡值 我需要获得卡[]手中的最大CardValue

在我缺乏知识的情况下,我想我能做的是用每张卡的所有卡值创建一个新的int[],但是有没有一种eaiser方法?

使用LINQ Max扩展方法:

var result = hand.Max(c => c.CardValue);
是的,LINQ有一种方法正好用于此目的:

int maxValue = hand.Max(card => card.CardValue);

你为此做了什么?