+ 6
How to generate random number?
How to generate random number (for example, between 0 and 10) in C#?
5 odpowiedzi
+ 22
// Random class is used for this purpose.
Random rnd = new Random();
int foundation = rnd.Next(0, 10);
// This generates numbers from 0-10;
+ 14
@Mark
Don't get me wrong. Yes, it excludes 10. This is what he asked. Random numbers between 0 and 10....What are you actually trying to describe me?
+ 7
Thanks Dayve.
I am quite okay to answer Python questions though
+ 6
@Dayve
I am a beginner so I could be mistaken, but in java I believe the random class will generate a number between 0 and 10 as you said, but 0 inclusive 10 excluded. so it would be 0-9 if you said new Random(0, 10).
Is it different in c#?
just curious 😉
+ 6
I was more or less asking for my own benefit. it's nice to know that the random class works the same in c# as it does in java. I was told they were similar languages.