Linq: How Indexing Operator works ( Lamda Expression)

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have just gone through some Sample LINQ expressions in Web. An Indexed Program is pretty puzzling. Hope many of you know about it. Please find the code attached below.
<pre class="prettyprint public void Linq5()
{
string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

var shortDigits = digits.Where((digit, index) => digit.Length < index);

Console.WriteLine("Short digits:");
foreach (var d in shortDigits)
{
Console.WriteLine("The word {0} is shorter than its value.", d);
}
}[/code]
Here the operator => is looking to behave very strange. I am new to this LINQ. oreover, I heard about this is a Lamda expression. While I search about Lamda Expression, I could not understand the behavior. Can anyone explain briefly

var shortDigits = digits.Where((digit, index) => digit.Length < index);

tells? I thought that digit and index are all
keywords . but it is not.
Kindly explain me.

<hr class="sig Viswa V

View the full article
 
Back
Top