DateTimeOffset - 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()
{
	DateTimeOffset [] values = { new DateTimeOffset(2017, 9, 1, 6, 45, 0, new TimeSpan(-7, 0, 0)),
							     new DateTimeOffset(2017, 11, 1, 6, 45, 0, new TimeSpan(-6, 0, 0)),
							     new DateTimeOffset(2017, 10, 1, 8, 45, 0, new TimeSpan(-5, 0, 0))};

    DateTimeOffset date = new DateTimeOffset(2007, 10, 1, 8, 45, 0, new TimeSpan(-5, 0, 0));

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

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 DateTimeOffset @this, params DateTimeOffset[] values)
    {
        return Array.IndexOf(values, @this) == -1;
    }
}