开发者

c# simple switch

开发者 https://www.devze.com 2023-01-13 03:11 出处:网络
Feel l开发者_JAVA百科ike an idiot :)Why does this not work? switch (sortCol) { case: \"username\" mnu_username.Text = \"\";

Feel l开发者_JAVA百科ike an idiot :) Why does this not work?

switch (sortCol)
{
case: "username"
    mnu_username.Text = "";
    break;
case default
    break;
}

Thanks!


switch (sortCol)
{
    case "username":
        mnu_username.Text = "";
        break;
    default:
        break;
}

Have you not got an IDE to highlight syntax errors for you?
Also note that if sortCol is not a string, this won't work.


case default should be changed to default:. Then your switch statement should work.


switch (sortCol)
            {
                case "username":
                    mnu_username.Text = "<img src=\"../images/" + sortType + ".png\" class=\"adIco\" />";
                    break;
                default:
                    break;
            }
0

精彩评论

暂无评论...
验证码 换一张
取 消