Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public enum Test {
- A = 1,
- B = 2,
- C = 3,
- D = 4,
- E = 5,
- F = 6,
- G = 7
- }
- public int TestWithSwitch(Test val) {
- switch(val) {
- case Test.A:
- return 0x00;
- case Test.B:
- return 0x01;
- case Test.C:
- return 0x02;
- case Test.D:
- return 0x03;
- case Test.E:
- return 0x04;
- case Test.F:
- return 0x05;
- case Test.G:
- return 0x06;
- default:
- return 0x7FFFFFFF;
- }
- }
- public int TestWithIf(Test val) {
- if(val == Test.A) {
- return 0x00;
- }
- else if(val == Test.B) {
- return 0x01;
- }
- else if(val == Test.C) {
- return 0x02;
- }
- else if(val == Test.D) {
- return 0x03;
- }
- else if(val == Test.E) {
- return 0x04;
- }
- else if(val == Test.F) {
- return 0x05;
- }
- else if(val == Test.G) {
- return 0x06;
- }
- else {
- return 0x7FFFFFFF;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement