A generate operation creates a new sequence of values.

Methods

MethodDescriptionQuery expression
DefaultIfEmptyReplace an empty collection with a default-valued singleton collectionN/A
EmptyReturn an empty collectionN/A
RangeGenerate a collection that contains a sequence of numbersN/A
RepeatGenerate a collection that contains one value repeated n timesN/A

Examples

IEnumerable<int> squares = Enumerable.Range(1, 10).Select(x => x * x);

squares.ForEach(i => Console.WriteLine(i)); // Output: 1 4 9 16 25 36 49 64 81 100