コード例 #1
0
        // ------------------ Events

        // ------------------ Serialized fields and properties

        // ------------------ Non-serialized fields

        // ------------------ Methods
        public void NextState()
        {
            if (CurrentState == CustomExampleSystem.States.Start)
            {
                CurrentState = CustomExampleSystem.States.Mid;
            }
            else if (CurrentState == CustomExampleSystem.States.Mid)
            {
                CurrentState = CustomExampleSystem.States.End;
            }
            else
            {
                SwitchStatementDefaultException.Throw(CurrentState);
            }

            //TODO: How to use CurrenState in switch? Currently it throws an error
//            switch (CurrentState)
//            {
//                case CustomExampleSystem.States.Start:
//                    CurrentState = CustomExampleSystem.States.End;
//                    break;
//                default:
//                    SwitchStatementDefaultException.Throw(CurrentState);
//                    break;
//            }
        }
コード例 #2
0
        // ------------------ Constants and statics

        // ------------------ Events

        // ------------------ Serialized fields and properties

        // ------------------ Non-serialized fields

        // ------------------ Methods
        public void NextState()
        {
            switch (CurrentState)
            {
            case State.Start:
                CurrentState = State.End;
                break;

            default:
                SwitchStatementDefaultException.Throw(CurrentState);
                break;
            }
        }