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
All: Checks if all elements in a collection satisfies a specified condition.
All: Checks if all elements in a collection satisfies a specified condition. |
All: Checks if all elements in a collection satisfies a specified condition. |
This Lambda Expression sample checks whether all names in array start with letter "B". |
This Lambda Expression sample checks whether all names in array start with letter "B". |
// A Query Expression cannot be constructed for All() in C#. // Consider using a Lambda Expression instead.
Private Shared Sub Sample_All_Linq() Dim names As String() = {"Bob", "Ned", "Amy", "Bill"} Dim result = Aggregate n In names Into All(n.StartsWith("B")) Debug.WriteLine("Does all of the names start with the letter 'B': ") Debug.WriteLine(result) End SubOutput:
Does all of the names start with the letter 'B': False
let Sample_All_Linq() = let names = [|"Bob"; "Ned"; "Amy"; "Bill"|] let result = query { for n in names do all (n.StartsWith "B") } Debug.WriteLine(sprintf "Does all of the names start with the letter 'B':") Debug.WriteLine(result);Output:
Does all of the names start with the letter 'B': False
static void Sample_All_Lambda() { string[] names = { "Bob", "Ned", "Amy", "Bill" }; var result = names.All(n => n.StartsWith("B")); Debug.WriteLine("Does all of the names start with the letter 'B':"); Debug.WriteLine(result); }Output:
Does all of the names start with the letter 'B': False
Private Shared Sub Sample_All_Lambda() Dim names As String() = {"Bob", "Ned", "Amy", "Bill"} Dim result = names.All(Function(n) n.StartsWith("B")) Debug.WriteLine("Does all of the names start with the letter 'B': ") Debug.WriteLine(result) End SubOutput:
Does all of the names start with the letter 'B': False
let Sample_All_Lambda() = let names = [|"Bob"; "Ned"; "Amy"; "Bill"|] let result = names.All(fun n -> n.StartsWith "B") Debug.WriteLine(sprintf "Does all of the names start with the letter 'B':") Debug.WriteLine(result);Output:
Does all of the names start with the letter 'B': False