Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. if (stars == 2 || stars ==6 || stars ==10)
  2. {
  3. do something
  4. }
  5.  
  6. if (stars == {2, 4, 6}) <--- MATLAB style
  7. {
  8. do something
  9. }
  10.  
  11. public static class GenericExtensions
  12. {
  13. public static bool In<T>(this T @this, params T[] listOfItems)
  14. {
  15. if (null == listOfItems) return false;
  16. return listOfItems.Contains(@this);
  17. }
  18. }
  19.  
  20. var items = new []{2,4,6};
  21. if(items.IndexOf(stars) > -1)
  22. {
  23. // do something
  24. }
  25.  
  26. var items = new List<int>{2,4,6};
  27. if(items.Contains(stars))
  28. {
  29. // do something
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement