开发者

c# simple switch

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜