Problems with a C# switch statement

I am making a paper scissors rock game and am receiving the following error:

Cannot implicitly convert type ‘int’ to ‘system.random’

namespace Rock__Paper__Scissors_CSNET
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("This is a Rock, Paper, Scissors game. Enter your choice below");
            Console.WriteLine("1. Rock");
            Console.WriteLine("2. Paper");
            Console.WriteLine("3. Scissors");
            string userInput = Console.ReadLine();
            Random Computer_Random = new Random();
            int randy = Computer_Random.Next(1, 4);
            switch (Computer_Random)
            {
              case 1:
                    break;

                case 2:
                    break;

                case 3:
                    break;
            }
            
        }

    }
}

What am I doing wrong?

>Solution :

Use switch (randy) instead.

namespace Rock__Paper__Scissors_CSNET
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("This is a Rock, Paper, Scissors game. Enter your choice below");
            Console.WriteLine("1. Rock");
            Console.WriteLine("2. Paper");
            Console.WriteLine("3. Scissors");
            string userInput = Console.ReadLine();
            Random Computer_Random = new Random();
            int randy = Computer_Random.Next(1, 4);
            switch (randy)
            {
              case 1:
                    break;

                case 2:
                    break;

                case 3:
                    break;
            }
            
        }

    }
}

Leave a Reply