String - NotIn
A T extension method to determines whether the object is not equal to any of the provided values.
public static void Main() { string [] values = {"EntityFramework", " ", "SQL", "", "Java", null}; string newValue = "Dapper"; // C# Extension Method: String - NotIn if(newValue.NotIn(values)) { Console.WriteLine("String: {0}", newValue); } }
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> public static bool NotIn(this String @this, params String[] values) { return Array.IndexOf(values, @this) == -1; } }