Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (stars == 2 || stars ==6 || stars ==10)
- {
- do something
- }
- if (stars == {2, 4, 6}) <--- MATLAB style
- {
- do something
- }
- public static class GenericExtensions
- {
- public static bool In<T>(this T @this, params T[] listOfItems)
- {
- if (null == listOfItems) return false;
- return listOfItems.Contains(@this);
- }
- }
- var items = new []{2,4,6};
- if(items.IndexOf(stars) > -1)
- {
- // do something
- }
- var items = new List<int>{2,4,6};
- if(items.Contains(stars))
- {
- // do something
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement