需要帮助C#textBox1.Text在当前上下文中不存在

时间:2015-06-19 21:33:26

标签: c#

        {
        if (("zipPath" == "XixanPackInstaller")) ;
        textBox1.Text = "Successfuly found XixanPackInstaller!";
    }
    else
        textBox1.Text = "Move XixanPackInstaller to your desktop!";
    }

我有这个代码并且它被破坏了,因为在visual studio上的else表示无效的令牌else而在textBox1.Text上它表示textBox1.text在当前上下文中不存在

2 个答案:

答案 0 :(得分:2)

{
        if (("zipPath" == "XixanPackInstaller")) //**;** also the semi-colon
        textBox1.Text = "Successfuly found XixanPackInstaller!";
    //}---please remove this bracket here
    else
        textBox1.Text = "Move XixanPackInstaller to your desktop!";
    }`enter code here`

答案 1 :(得分:1)

你最好在这里使用三元运算符?:,如

textBox1.Text = ("zipPath" == "XixanPackInstaller") ?
   "Successfuly found XixanPackInstaller!" :
        "Move XixanPackInstaller to your desktop!";