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
Select: Selects, projects and transforms elements in a collection. Can be overloaded to get element index.
Select: Selects, projects and transforms elements in a collection. Can be overloaded to get element index. |
Select: Selects, projects and transforms elements in a collection. Can be overloaded to get element index. |
This Lambda Expression sample selects word and element index from array. |
This Lambda Expression sample selects word and element index from array. |
// A Query Expression cannot be constructed for Select() with index in C#. // Consider using a Lambda Expression instead.
' A Query Expression cannot be constructed for Select() with index in VB.NET. ' Consider using a Lambda Expression instead.
// A Query Expression cannot be constructed for Select() with index in F#. // Consider using a Lambda Expression instead.
static void Sample_Select_Lambda_Indexed() { string[] words = { "one", "two", "three" }; var result = words.Select((w, i) => new { Index = i, Value = w }); Debug.WriteLine("Words with index and value:"); foreach (var word in result) Debug.WriteLine(String.Format("Index {0} is {1}", word.Index, word.Value)); }Output:
Words with index and value: Index 0 is one Index 1 is two Index 2 is three
Private Shared Sub Sample_Select_Lambda_Indexed() Dim words As String() = {"one", "two", "three"} Dim result = words.Select(Function(w, i) New With { _ Key .Index = i, _ Key .Value = w _ }) Debug.WriteLine("Words with index and value:") For Each word In result Debug.WriteLine(String.Format("Index {0} is {1}", word.Index, word.Value)) Next End SubOutput:
Words with index and value: Index 0 is one Index 1 is two Index 2 is three