In & NotIn extension methods


/ Published in: C#
Save to your folder(s)

I love creating simple little extension methods like these to improve code readability.


Copy this code and paste it in your HTML
  1. public static bool In<T>(this T value, params T[] values)
  2. {
  3. return values.Contains(value);
  4. }
  5.  
  6. public static bool NotIn<T>(this T value, params T[] values)
  7. {
  8. return !In(value, values);
  9. }

URL: InNotIn

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.