Unreachable code detected in case statement

前端 未结 14 2499
终归单人心
终归单人心 2020-12-06 16:37

I have a code:

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        switch (keyData)
        {
            case Keys.Alt|Ke         


        
14条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 17:08

    I understand that this doesn't answer the question directly, but inspired by the various answers here I just wanted to add another variation on how the "switch" could be structured:

    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
        if (keyData == Keys.Alt|Keys.D1 && _condition1)
            return true;
    
        if (keyData == Keys.Control|Keys.U && _condition2)
            return true;
    
        // ...repeat for other variations
    
        return base.ProcessCmdKey(ref msg, keyData);
    }
    

提交回复
热议问题