jeudi 14 octobre 2021

What will the be the effect(s) of adding 20 to the code? [closed]

So this subroutine simulates the rolling of a 12-sided dice. The code works fine as it is below but I'm told that if I write "Random Number = new Random(20);" instead of "Random Number = new Random();" it will change the output somehow. I'm not sure what modifying it to 20 will even do?

// Number data types
using System;
namespace ConsoleApp1
{
    class Program
    {
        // Subroutine to generate a random number
        static int RollDice()
        {
            Random Number = new Random();
            return Number.Next(1,13);
        }
        //Main program
        static void Main(string[] args)
        {
            int Dice = RollDice();
            Console.WriteLine("Rolled a {0}", Dice);
        }
    }
}



Aucun commentaire:

Enregistrer un commentaire