0

So I get the error:

A namespace cannot directly contain members such as fields or methods.

I double click it and it takes me to the line 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

Any suggestions on how to fix?

Jeroen Vannevel
  • 43,651
  • 22
  • 107
  • 170
  • 1
    Have you considered not directly putting your methods and fields (and statements) in a namespace? Instead use a namespace to store a class to store a method to store a statement. I'm guessing this is C#? – Jeroen Vannevel Dec 29 '13 at 05:31
  • There are far too many things in your code with no context. What are "dialog", "client", and "npcRequest", for instance? We can't read your mind or see your screen from where we're sitting. – Ken White Dec 29 '13 at 05:32
  • Possible duplicate of ["A namespace cannot directly contain members such as fields or methods" in Net.Reflector](https://stackoverflow.com/questions/21175781/a-namespace-cannot-directly-contain-members-such-as-fields-or-methods-in-net-r) – Jaider Oct 25 '19 at 22:47

1 Answers1

2

Well, a case statement should be inside a function definition so my guess is you are missing a closing brace somewhere and this block of code appears to be inside a namespace. (By the way the level of indentation here is troubling...)

Spearman
  • 149
  • 6