Aggregation
Aggregate, Average, Count, LongCount, Max, Min, Sum
Conversion
AsEnumerable, Cast, OfType, ToArray, ToDictionary, ToList, ToLookup
Element
ElementAt, ElementAtOrDefault, First, FirstOrDefault, Last, LastOrDefault, Single, SingleOrDefault
ElementAt
ElementAtOrDefault
First (simple)
First (conditional)
FirstOrDefault
Last
LastOrDefault (simple)
LastOrDefault (conditional)
Single
SingleOrDefault
Generation
DefaultIfEmpty, Empty, Range, Repeat
Grouping
GroupBy
Join
GroupJoin, Join
Ordering
OrderBy, OrderByDescending, Reverse, ThenBy, ThenByDescending
OrderBy (simple - numbers)
OrderBy (simple - dates)
OrderBy (simple - objects)
OrderByDescending
Reverse
ThenBy
ThenByDescending
Other
Concat, SequenceEqual, Zip
Partitioning
Skip, SkipWhile, Take, TakeWhile
Projection
Select, SelectMany
Quantifiers
All, Any, Contains
Restriction
Where
Set
Distinct, Except, Intersect, Union
Close
ElementAt: Retrieves element from a collection at specified (zero-based) index.
ElementAt: Retrieves element from a collection at specified (zero-based) index. |
ElementAt: Retrieves element from a collection at specified (zero-based) index. |
This Lambda Expression sample retrieves second element from an array. |
This Lambda Expression sample retrieves second element from an array. |
// A Query Expression cannot be constructed for ElementAt() in C#. // Consider using a Lambda Expression instead.
' A Query Expression cannot be constructed for ElementAt() in VB.NET. ' Consider using a Lambda Expression instead.
// There is no ElementAt() for Query Expressions in F#, but it has the similar "nth". let Sample_ElementAt_Linq() = let words = [|"One"; "Two"; "Three"|] let result = query { for w in words do nth 1 } Debug.WriteLine(sprintf "Element at index 1 in the array is:") Debug.WriteLine(sprintf "%s" result)Output:
Element at index 1 in the array is: Two
static void Sample_ElementAt_Lambda() { string[] words = { "One", "Two", "Three" }; var result = words.ElementAt(1); Debug.WriteLine("Element at index 1 in the array is:"); Debug.WriteLine(result); }Output:
Element at index 1 in the array is: Two
Private Shared Sub Sample_ElementAt_Lambda() Dim words As String() = {"One", "Two", "Three"} Dim result = words.ElementAt(1) Debug.WriteLine("Element at index 1 in the array is:") Debug.WriteLine(result) End SubOutput:
Element at index 1 in the array is: Two
let Sample_ElementAt_Lambda() = let words = [|"One"; "Two"; "Three"|] let result = words.ElementAt(1) Debug.WriteLine(sprintf "Element at index 1 in the array is:") Debug.WriteLine(sprintf "%s" result)Output:
Element at index 1 in the array is: Two