Windows Phone Developers

Wednesday, May 11, 2011

Control cannot fall through from one case label - Switch Statement (C#/CSharp)

This error occurs when there are no jump statement in the switch. Like the following

switch  (sDayName.ToUpper () )
            {
                case"1":
                    MessageBox.Show("One");
                case "2":
                    MessageBox.Show("Two");
        }

A break or goto statement should solve the problem

switch  (sDayName.ToUpper () )
            {
                case"1":
                    MessageBox.Show("One");
                    break;
                case "2":
                    MessageBox.Show("Two");
                    goto default;
...

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

No comments:

Post a Comment

kbAlertz.com :: Visual Studio 2005

kbAlertz.com :: Visual Studio 2008

kbAlertz.com :: Visual Basic 2005