Last active
August 29, 2015 14:17
-
-
Save caseywatson/af1e24efaa4faa0e25b7 to your computer and use it in GitHub Desktop.
OnlyOne Extension 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
public static bool OnlyOne<T>(this IEnumerable<T> source, Func<T, bool> condition = null) | |
{ | |
return (source.Count(condition ?? (t => true)) == 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment