In & NotIn extension methods

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

I love creating simple little extension methods like this to make my code read more better.

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. }
  6. public static bool NotIn<T>(this T value, params T[] values)
  7. {
  8. return !In(value, values);
  9. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.