Decimal - NotIn

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

Try it

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

    // C# Extension Method: Decimal - NotIn
    if(searchVal.NotIn(values))
	{
		Console.WriteLine("{0} doesn't exists in the list.", searchVal);
	}
	else
	{
		Console.WriteLine("{0} 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 not 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 doesn't contains the object, else false.</returns>
    /// ###
    /// <typeparam name="T">Generic type parameter.</typeparam>
    public static bool NotIn(this Decimal @this, params Decimal[] values)
    {
        return Array.IndexOf(values, @this) == -1;
    }
}