ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods


Determines if an instance is not contained in a sequence. Is the equivalent of Contains == false, but allows a more fluent reading "if item is not in list", specially useful in LINQ extension methods like Where.


public static bool IsNotIn<T>(this T keyObject, IEnumerable<T> collection)
    return keyObject.IsIn(collection) == false;


var exceptionList = new List<string> { "exception1", "exception2" };
var query = myEntities.MyEntity
.Select(e => e.Name)
.Where(e => e.IsNotIn(exceptionList));

Author: Joan Comas

Submitted on: 20 apr 2016

Language: C#

Type: Generic

Views: 4020