Guid - In
A T extension method to determines whether the object is equal to any of the provided values.
public static void Main() { Guid guid = Guid.NewGuid(); Guid[] guids = new Guid[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), guid }; // C# Extension Method: Guid - In if(guid.In(guids)) { Console.WriteLine("{0} exists in the list.", guid); } else { Console.WriteLine("{0} doesn't exists in the list.", guid); } }
View Source
using System; public static partial class Extensions { /// <summary> /// A T extension method to determines whether the object is 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 contains the object, else false.</returns> /// ### /// <typeparam name="T">Generic type parameter.</typeparam> public static bool In(this Guid @this, params Guid[] values) { return Array.IndexOf(values, @this) != -1; } }