1
class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Welcome To The Random.");    
        System.Threading.Thread.Sleep(1000);

        choosing:

        Console.WriteLine("Roll Standard Dice (D), Flip a Coin (2), 8-Ball (8), or Random Number 1-10 (R)");

        ConsoleKeyInfo result = Console.ReadKey();    
        if ((result.KeyChar == 'D') || (result.KeyChar == 'd'))
        {
            Console.WriteLine("Standard Dice Has been chosen, do you want to continue? Y/N");    
            ConsoleKeyInfo RSD = Console.ReadKey();

            if ((RSD.KeyChar == 'Y') || (RSD.KeyChar == 'y'))
            {
                Console.Write("Rolling");    
                Console.Write(".");    
                Console.Write(".");    
                Console.Write(".");    
            }
            else if ((RSD.KeyChar == 'N') || (RSD.KeyChar == 'n'))
            {
                Console.Clear();
                goto choosing;
            }
        }
        else if ((result.KeyChar == '2'))
        {
            Console.WriteLine("I wont do anything");
        }
        else if ((result.KeyChar == '8'))
        {
        }
        else if ((result.KeyChar == 'R') || (result.KeyChar == 'r'))
        {
        }

        *Random* rnd = new *Random*();
    }
}

The parts in asterix are the part where it is a red line and it says Random is a namespace but it's used like a variable. The Random thing normally works but I'm not sure why it isn't working now if you could please help me that would be appreciated.

Gilad Green
  • 36,708
  • 7
  • 61
  • 95
  • 3
    Do not use `goto`! [goto is this bad?](https://stackoverflow.com/q/11906056/6400526) – Gilad Green Jul 30 '17 at 07:50
  • Yeah, I can only support @Gilad Green in this. I know, it has nothing to do with the question (which is already answered), but **never** use go-to, you will end up with Spaghetti code: https://en.wikipedia.org/wiki/Spaghetti_code. – Markus Weninger Jul 30 '17 at 07:52
  • dude! why did you remove the answer? – Sajeetharan Aug 03 '17 at 04:02

2 Answers2

8

Your project's namespace is also Random, change it to some other name,

namespace Random

to

namespace Sample

Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
2

You're declaring a type with the same name as the namespace it's in. Don't do that. Change you namespace to some other name than Random

Some further instructions on Do not name a class the same as its namespace, Part One

Tushar Gupta
  • 15,504
  • 1
  • 29
  • 47