检测到无法访问的代码

xrx*_*215 1 c#

我为第二个if语句检测到无法访问的代码.你能告诉我出了什么问题吗?

private bool ValidateSettings()
{
    if (chkDownload.Checked && String.IsNullOrEmpty(txtAppName.Text))
    {
        divAppDownloadError.Visible=true;
        return false;
    }
    else
    {
        return true;
    }

    if (chkpplaORfmp.Checked && String.IsNullOrEmpty(txtfmpORppla.Text))
    {
        divXPAAPPDownloadError.Visible = true;
        return false;
    }
    else
    {
         return true;
    }
}
Run Code Online (Sandbox Code Playgroud)

And*_*are 26

这是因为第一个if/else块将以任一方式返回 - 该块之后的代码将不会执行:

if(chkDownload.Checked && String.IsNullOrEmpty(txtAppName.Text))
{
    // You either return here
    divAppDownloadError.Visible=true;
    return false;
}
else
{
    // or here - after this statement how can anything
    // else possible execute?
    return true;
}
Run Code Online (Sandbox Code Playgroud)