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 妈妈生日祝福语简短励志