1
Answer

Multiple Random Numbers

Christopher

Christopher

14y
2.1k
1
Hi there,

I'm a noob, so please dumb it down for me.

I'm trying to output multiple random numbers.

Why doesn't the code below work?



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lab5Ex_2
{
    class Program
    {
        static void Main(string[] args)
        {

            for (int z = 0; z < 36; z++)
            {

                Random RandomNumber = new Random();

                int answer = RandomNumber.Next(1, 6);
                int answer2 = RandomNumber.Next(1, 6);

                int total = answer + answer2;



                Console.WriteLine(answer + " and " + answer2);
                Console.WriteLine("The total is " + total);
            }
            Console.Read();

        }
    }
}

Thanks for taking a look,

Chris

Answers (1)