Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Lambda Expressions in C#
A lambda expression in C# describes a pattern.
Lambda Expressions has the token => in an expression context. This is read as “goes to” operator and used when a lambda expression is declared.
Here, we are finding the first occurrence of the element greater than 50 from a list.
list.FindIndex(x => x > 50);
Above the token => is used. The same is shown below −
Example
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);
}
}
Output
Index: 4
Advertisements
