12
หลีกเลี่ยงวูดู `goto 'หรือไม่
ฉันมีswitchโครงสร้างที่มีหลายกรณีที่ต้องจัดการ การswitchดำเนินการมากกว่าenumที่ poses ปัญหาของรหัสที่ซ้ำกันผ่านค่ารวม: // All possible combinations of One - Eight. public enum ExampleEnum { One, Two, TwoOne, Three, ThreeOne, ThreeTwo, ThreeOneTwo, Four, FourOne, FourTwo, FourThree, FourOneTwo, FourOneThree, FourTwoThree, FourOneTwoThree // ETC. } ขณะนี้switchโครงสร้างจัดการแต่ละค่าแยกกัน: // All possible combinations of One - Eight. switch (enumValue) { case One: DrawOne; break; …