Random - one of

A Random extension method that return a random value from the specified values.

Try it

public static void Main()
{
    var random = new Random();

	//C# Extension Method: Random - OneOf
    Console.WriteLine(random.OneOf(1, 2, 3, 4));
	Console.WriteLine(random.OneOf("a", "b", "c", "d"));
	Console.WriteLine(random.OneOf(1, "a", DateTime.Now, new object()));
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     A Random extension method that return a random value from the specified values.
    /// </summary>
    /// <typeparam name="T">Generic type parameter.</typeparam>
    /// <param name="this">The @this to act on.</param>
    /// <param name="values">A variable-length parameters list containing arguments.</param>
    /// <returns>One of the specified value.</returns>
    public static T OneOf<T>(this Random @this, params T[] values)
    {
        return values[@this.Next(values.Length)];
    }
}