Char - Repeat

A char extension method that repeats a character the specified number of times.

Try it

public static void Main()
{	
	char input = '.';

    // C# Extension Method: Char - Repeat
	string output = input.Repeat(3);
    
	Console.WriteLine(output);
}

View Source
public static partial class Extensions
{
    /// <summary>
    ///     A char extension method that repeats a character the specified number of times.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <param name="repeatCount">Number of repeats.</param>
    /// <returns>The repeated char.</returns>
    public static string Repeat(this char @this, int repeatCount)
    {
        return new string(@this, repeatCount);
    }
}