Double - In

A T extension method to determines whether the object is equal to any of the provided values.

Try it

public static void Main()
{
	double searchVal = 7.64;
	
	double[] values = { 32.7865, 7.03, 7.64, 0.12, -0.12, -7.1, -7.6, -32.9012 };

    // C# Extension Method: Double - In
    if(searchVal.In(values))
	{
		Console.WriteLine("{0} exists in the list.", searchVal);
	}
	else
	{
		Console.WriteLine("{0} doesn't exists in the list.", searchVal);
	}
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     A T extension method to determines whether the object is equal to any of the provided values.
    /// </summary>
    /// <param name="this">The object to be compared.</param>
    /// <param name="values">The value list to compare with the object.</param>
    /// <returns>true if the values list contains the object, else false.</returns>
    /// ###
    /// <typeparam name="T">Generic type parameter.</typeparam>
    public static bool In(this Double @this, params Double[] values)
    {
        return Array.IndexOf(values, @this) != -1;
    }
}