开发者

C# case statement issue

making an app for WP7 but have come across this case statement error. It appears on the 3rd case. Gives the "cannot fall through case error". I've googled this error and unless im not concentrating properly i'm sure i've set everything up correctly.

private void SortFeedData(int fs)
    {
        //only using cases 1,2,3 since 0 is for the news page which doesn't need sorting
        switch (fs)
        {
            case 1:
                //Sort feed data for "Scores" Page
                switch (ButtonSourceLeague)
                {
                    case "Premier League":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - BBC Football RSS Feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/premier-league.aspx");
                        break;
                    case "Championship":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - Test feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/engchamp-league.aspx");
                        break;
                    case "League One":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - BBC Football RSS Feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/premier-league.aspx");
                        break;
                    case "League Two":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - BBC Football RSS Feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/premier-league.aspx");
                        break;
                    case "FA Cup":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - BBC Football RSS Feed
   开发者_C百科                     App.Data.FeedList.Add("http://www.rsslivescores.com/fa-cup.aspx");
                        break;
                    case "League Cup":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - BBC Football RSS Feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/english-league-cup.aspx");
                        break;
                    default:
                        MessageBox.Show("Error");
                        break;
                }

                break;
            case 2:
                //Sort feed data for "Fixtures" Page

                switch (ButtonSourceLeague)
                {
                    case "Premier League":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - BBC Football RSS Feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/premier-league.aspx");
                        break;
                    case "Championship":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - Test feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/RssTestFeed.aspx");
                        break;
                    case "League One":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - BBC Football RSS Feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/premier-league.aspx");
                        break;
                    case "League Two":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - BBC Football RSS Feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/premier-league.aspx");
                        break;
                    case "FA Cup":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - BBC Football RSS Feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/premier-league.aspx");
                        break;
                    case "League Cup":
                        //clears all current feed data
                        App.Data.FeedList.Clear();
                        //For News Page - BBC Football RSS Feed
                        App.Data.FeedList.Add("http://www.rsslivescores.com/premier-league.aspx");
                        break;
                    default:
                        MessageBox.Show("Error");
                        break;
                }
                //Sort feed data for "My Club" Page

                //Either a big-ass case statment for EVERY club we know off
                //OR find a SINGLE rss feed that has info on ALL clubs

                break;
            case 3:

                switch (ButtonSourceClub)
                {

                    case "Manchester United":

                        App.Data.FeedList.Add("rss xml link here");
                        break;
                    default:
                        MessageBox.Show("Error");
                        break;
                }
        }
    }


}

}


        case 3:

            switch (ButtonSourceClub)
            {

                case "Manchester United":

                    App.Data.FeedList.Add("rss xml link here");
                    break;
                default:
                    MessageBox.Show("Error");
                    break;
            }
            break; //Here's what you're missing.


In case 3: you don't have a break statement outside the inner switch. Therefore there is an implicit fall through to the next statement (even though there isn't a next statement).


The third case misses a break statement:

            break;
        case 3:

            switch (ButtonSourceClub)
            {

                case "Manchester United":

                    App.Data.FeedList.Add("rss xml link here");
                    break;
                default:
                    MessageBox.Show("Error");
                    break;
            }
            break; // <---- was missing
    }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜