命名空间不能直接包含字段或方法等成员。

时间:2013-12-29 05:28:59

标签: c#

所以我收到错误:

  

命名空间不能直接包含字段或方法等成员。

我双击它,它将我带到case: 1002

     #region Vip Seller
            case 1002:
               {
                    switch (npcRequest.OptionID)
                    {
                        case 0:
                            {
                                if (client.Entity.VIPLevel == 6)
                                {
                                    dialog.Text("your Are already VIP 6.");
                                    dialog.Option("I see.", 255);
                                    dialog.Avatar(116);
                                    dialog.Send();
                                    break;
                                }
                                dialog.Text("Hay i will upgrade your VIP for cps");
                                dialog.Option("[VIP 1] 20k cps.", 1);
                                dialog.Option("[VIP 2] 20k cps.", 2);
                                dialog.Option("[VIP 3] 15k cps.", 3);
                                dialog.Option("[VIP 4] 30k cps.", 4);
                                dialog.Option("[VIP 5] 15k cps.", 5);
                                dialog.Option("[VIP 6] 20k cps.", 6);
                                dialog.Option("Just passing by.", 255);
                                dialog.Avatar(116);
                                dialog.Send();
                                break;

                            }
                        case 1:
                            {
                                if (client.Entity.VIPLevel == 0 && client.Entity.VIPLevel < 1)
                                {
                                    if (client.Entity.ConquerPoints >= 20000)
                                    {
                                        client.Entity.ConquerPoints -= 20000;
                                        client.Entity.VIPLevel = 1;

                                    }

                                    else
                                    {
                                        dialog.Text("Please take 20k cps.");
                                        dialog.Option("I see.", 255);
                                        dialog.Avatar(116);
                                        dialog.Send();
                                    }

                                }
                                else
                                {
                                    dialog.Text("Sorry Can't upgrade any more.");
                                    dialog.Option("I see.", 255);
                                    dialog.Avatar(116);
                                    dialog.Send();
                                }

                                break;
                            }
                        case 2:
                            {
                                if (client.Entity.VIPLevel == 1)
                                {
                                    if (client.Entity.ConquerPoints >= 20000)
                                    {
                                        client.Entity.ConquerPoints -= 20000;
                                        client.Entity.VIPLevel = 2;
                                    }

                                    else
                                    {
                                        dialog.Text("Please take 20k cps.");
                                        dialog.Option("I see.", 255);
                                        dialog.Avatar(116);
                                        dialog.Send();
                                    }


                                }
                                else
                                {
                                    dialog.Text("Sorry Can't upgrade any more.");
                                    dialog.Option("I see.", 255);
                                    dialog.Avatar(116);
                                    dialog.Send();
                                }
                                break;
                            }
                        case 3:
                            {
                                if (client.Entity.VIPLevel == 2)
                                {
                                    if (client.Entity.ConquerPoints >= 15000)
                                    {
                                        client.Entity.ConquerPoints -= 15000;
                                        client.Entity.VIPLevel = 3;
                                    }

                                    else
                                    {
                                        dialog.Text("Please take 15k cps.");
                                        dialog.Option("I see.", 255);
                                        dialog.Avatar(116);
                                        dialog.Send();
                                    }


                                }
                                else
                                {
                                    dialog.Text("Sorry Can't upgrade any more.");
                                    dialog.Option("I see.", 255);
                                    dialog.Avatar(116);
                                    dialog.Send();
                                }
                                break;
                            }
                        case 4:
                            {
                                if (client.Entity.VIPLevel == 3)
                                {
                                    if (client.Entity.ConquerPoints >= 30000)
                                    {
                                        client.Entity.ConquerPoints -= 30000;
                                        client.Entity.VIPLevel = 4;
                                    }

                                    else
                                    {
                                        dialog.Text("Please take 150k cps.");
                                        dialog.Option("I see.", 255);
                                        dialog.Avatar(116);
                                        dialog.Send();
                                    }

                                }
                                else
                                {
                                    dialog.Text("Sorry Can't upgrade any more.");
                                    dialog.Option("I see.", 255);
                                    dialog.Avatar(116);
                                    dialog.Send();
                                }
                                break;
                            }
                        case 5:
                            {
                                if (client.Entity.VIPLevel == 4)
                                {
                                    if (client.Entity.ConquerPoints >= 15000)
                                    {
                                        client.Entity.ConquerPoints -= 15000;
                                        client.Entity.VIPLevel = 5;
                                    }

                                    else
                                    {
                                        dialog.Text("Please take 15k cps.");
                                        dialog.Option("I see.", 255);
                                        dialog.Avatar(116);
                                        dialog.Send();

                                    }

                                }
                                else
                                {
                                    dialog.Text("Sorry Can't upgrade any more.");
                                    dialog.Option("I see.", 255);
                                    dialog.Avatar(116);
                                    dialog.Send();
                                }
                                break;
                            }
                        case 6:
                            {
                                if (client.Entity.VIPLevel == 5)
                                {
                                    if (client.Entity.ConquerPoints >= 20000)
                                    {
                                        client.Entity.ConquerPoints -= 20000;
                                        client.Entity.VIPLevel = 6;
                                    }

                                    else
                                    {
                                        dialog.Text("Please take 20k cps.");
                                        dialog.Option("I see.", 255);
                                        dialog.Avatar(116);
                                        dialog.Send();

                                    }

                                }
                                else
                                {
                                    dialog.Text("Sorry Can't upgrade any more.");
                                    dialog.Option("I see.", 255);
                                    dialog.Avatar(116);
                                    dialog.Send();
                                }
                                break;
                            }
                    }
                    break;
                }
            #endregion

有关如何修复的任何建议吗?

1 个答案:

答案 0 :(得分:2)

好吧,一个case语句应该在一个函数定义中,所以我猜你在某个地方缺少一个右括号,这个代码块似乎在一个命名空间里面。 (顺便说一句,这里的缩进程度令人不安......)