Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public enum Test {
  2. A = 1,
  3. B = 2,
  4. C = 3,
  5. D = 4,
  6. E = 5,
  7. F = 6,
  8. G = 7
  9. }
  10.  
  11. public int TestWithSwitch(Test val) {
  12. switch(val) {
  13. case Test.A:
  14. return 0x00;
  15. case Test.B:
  16. return 0x01;
  17. case Test.C:
  18. return 0x02;
  19. case Test.D:
  20. return 0x03;
  21. case Test.E:
  22. return 0x04;
  23. case Test.F:
  24. return 0x05;
  25. case Test.G:
  26. return 0x06;
  27. default:
  28. return 0x7FFFFFFF;
  29. }
  30. }
  31.  
  32. public int TestWithIf(Test val) {
  33. if(val == Test.A) {
  34. return 0x00;
  35. }
  36. else if(val == Test.B) {
  37. return 0x01;
  38. }
  39. else if(val == Test.C) {
  40. return 0x02;
  41. }
  42. else if(val == Test.D) {
  43. return 0x03;
  44. }
  45. else if(val == Test.E) {
  46. return 0x04;
  47. }
  48. else if(val == Test.F) {
  49. return 0x05;
  50. }
  51. else if(val == Test.G) {
  52. return 0x06;
  53. }
  54. else {
  55. return 0x7FFFFFFF;
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement