CKTIS / C#
Enumerable.Repeat: practical reference
Enumerable.Repeat: practical reference: Creates a deferred sequence containing the same value count times.
Version: .NET LINQ; verified on .NET 10.0.14
Syntax
source.Repeat(/* overload-specific arguments */)Creates a deferred sequence containing the same value count times.
Use it for fills and constant-value test sequences. For an object, the same reference is repeated, not clones.
Mutating the repeated object is visible at every position because all positions reference the same instance.
A negative count throws ArgumentOutOfRangeException; count 0 yields an empty sequence.
The complete program actually uses Enumerable.Repeat; its exact expected stdout is x,x,x.
Examples
using System;
using System.Collections.Generic;
using System.Linq;
Console.WriteLine(string.Join(",", Enumerable.Repeat("x", 3)));
Result
x,x,x
The complete program actually uses `Enumerable.Repeat`; its exact expected stdout is `x,x,x`.