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
Repeat: Creates a collection of repeated elements, where first argument is value to repeat, and second argument is number of times to repeat.
Repeat: Creates a collection of repeated elements, where first argument is value to repeat, and second argument is number of times to repeat. |
Repeat: Creates a collection of repeated elements, where first argument is value to repeat, and second argument is number of times to repeat. |
This Query Expression sample repeats the word "Banana" 5 times. |
This Query Expression sample repeats the word "Banana" 5 times. |
static void Sample_Repeat_Linq() { string word = "Banana"; var result = from w in Enumerable.Repeat(word, 5) select w; Debug.WriteLine("String is repeated 5 times:"); foreach (string str in result) Debug.WriteLine(str); }Output:
String is repeated 5 times: Banana Banana Banana Banana Banana
Private Shared Sub Sample_Repeat_Linq() Dim word As String = "Banana" Dim result = From w In Enumerable.Repeat(word, 5) Debug.WriteLine("String is repeated 5 times:") For Each str As String In result Debug.WriteLine(str) Next End SubOutput:
String is repeated 5 times: Banana Banana Banana Banana Banana
let Sample_Repeat_Linq() = let word = "Banana" let result = query { for n in Enumerable.Repeat(word, 5) do select n } Debug.WriteLine(sprintf "String is repeated 5 times:") for str in result do Debug.WriteLine(sprintf "%s" str)Output:
String is repeated 5 times: Banana Banana Banana Banana Banana
static void Sample_Repeat_Lambda() { string word = "Banana"; var result = Enumerable.Repeat(word, 5); Debug.WriteLine("String is repeated 5 times:"); foreach (string str in result) Debug.WriteLine(str); }Output:
String is repeated 5 times: Banana Banana Banana Banana Banana
Private Shared Sub Sample_Repeat_Lambda() Dim word As String = "Banana" Dim result = Enumerable.Repeat(word, 5) Debug.WriteLine("String is repeated 5 times:") For Each str As String In result Debug.WriteLine(str) Next End SubOutput:
String is repeated 5 times: Banana Banana Banana Banana Banana
let Sample_Repeat_Lambda() = let word = "Banana" let result = Enumerable.Repeat(word, 5) Debug.WriteLine(sprintf "String is repeated 5 times:") for str in result do Debug.WriteLine(sprintf "%s" str)Output:
String is repeated 5 times: Banana Banana Banana Banana Banana