SByte - 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()
{
	sbyte searchVal = -12;

    // C# Extension Method: SByte - NotIn
	Display(searchVal, searchVal.NotIn(127, 35, 0, -12, -127));
	Display(searchVal, searchVal.NotIn(127, 35, 0, -13, -127));
    
}

public static void Display(object searchVal, bool status)
{
	if(status)
	{
		Console.WriteLine("{0} is not in the list.", searchVal);
	}
	else
	{
		Console.WriteLine("{0} is 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 SByte @this, params SByte[] values)
    {
        return Array.IndexOf(values, @this) == -1;
    }
}