I’m a developer with 15-years of experience in the .Net stack as well as an interest in Angular.I’m known for taking legacy projects and updating them so they can be maintainable and have new features
You'd end up with several repeating numbers as it's calculating off the same timestamp. This is fine for small sets of random numbers just don't go newing up Random() for a large set.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The quick and dirty way in C# to get one random number is:
Keep in mind that
Random()
initializes with the current timestamp so you can't use it in rapid succession and expect a random result.It's important to note what we're doing in the two functions. We're always adding a
new Random()
i.eoutput.Add(new Random().Next(min, max));
Why? Because we get a new timestamp when we do so.
If instead, you did something like this:
You'd end up with several repeating numbers as it's calculating off the same timestamp. This is fine for small sets of random numbers just don't go newing up
Random()
for a large set.