C#中的Lambda表达式
C#中的lambda表达式描述了一种模式。
LambdaExpressions在表达式上下文中具有标记=>。这被读为“转到”运算符,并在声明lambda表达式时使用。
在这里,我们从列表中找到大于50的元素的首次出现。
list.FindIndex(x => x > 50);
在令牌上方使用=>。如下所示-
示例
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
List<int> list = new List<int> { 44, 6, 34, 23, 78 };
int res = list.FindIndex(x => x > 50);
Console.WriteLine("Index: "+res);
}
}输出结果
Index: 4
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短