Created
May 3, 2012 20:02
-
-
Save jonsagara/2588852 to your computer and use it in GitHub Desktop.
C# In() method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Checks to see if source is in the items collection. | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="source"></param> | |
/// <param name="items"></param> | |
/// <returns></returns> | |
public static bool In<T>(this T source, params T[] items) | |
{ | |
if (items == null) | |
{ | |
throw new ArgumentNullException("items"); | |
} | |
return items.Contains(source); | |
} | |
/// <summary> | |
/// Checks to see if source is in the items collection. | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="source"></param> | |
/// <param name="items"></param> | |
/// <returns></returns> | |
public static bool In<T>(this T source, IEnumerable<T> items) | |
{ | |
if (items == null) | |
{ | |
throw new ArgumentNullException("items"); | |
} | |
return items.Contains(source); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment