I need to create a random number for a game, but because I am just learning how to code I juts used examples I found on the Internet. While that was more or less always the same code, implementing it brought me 3 errors in 2 lines of code and I don't understand why.
The code I used:
Random rnd = new Random();
int num = rnd.Next(1, 11);
I expected it to give me a number between 1 and 10 but instead I get the errors:
Cannot declare a variable of static type 'Random'; Cannot create an instance of the static class 'Random'and 'Random' does not contain a definition for 'Next' and no accessible extension method 'Next'accepting a first argument of type 'Random' could be found (are you missing a using directive or an assembly reference?)
I'm not sure what I did wrong and I also don't know what I'm supposed to do to fix it. it would be really nice if somebody could help me
Aucun commentaire:
Enregistrer un commentaire