lundi 30 janvier 2023

How to generate a set of numbers consisting of a certain number of numbers in C#?

I have to generate a set of numbers consisting of 5 numbers, as shown below. I tried to search some info about this but found nothing.

int playerId;

System.Random rand = new System.random();
for (int i = 0; i <= 5; i++)
{
     playerId = random.Next();
}
Console.Write($"Generating player ID: {playerId}");

// output example: Generating player ID:  1158453178

As a result, i got a set of numbers consisting of 10 numbers. How can i solve this problem?




Aucun commentaire:

Enregistrer un commentaire