Linked Questions

848 votes
15 answers
253k views

I have the following function: //Function to get random number public static int RandomNumber(int min, int max) { Random random = new Random(); return random.Next(min, max); } How I call it: ...
Ivan Prodanov's user avatar
0 votes
0 answers
64 views

For a school assignment I am currently working on a small project involving a console application. it fills a grid with random traffic objects (like bicycles and cars). Every time a traffic object is ...
Pim Schwippert's user avatar
8 votes
2 answers
6k views

I have recently been discussing the initialisation of multiple random number generators of the same type in the comments of another post and in that discussion we asked the following questions: 1) Is ...
Andrew's user avatar
  • 769
2 votes
2 answers
8k views

I need to generate random int in C#. I am using clock time to set the seend. However, as the rnd.Next() function may take less than a millisecond, this does not work if one has to generate a list of ...
Nic's user avatar
  • 1,310
2 votes
6 answers
375 views

I have a method called "GetValue()" which is supposed to return the value "A", "B", "C" or "D" on each method call. I want this method to return the value "A" in 30% of the method calls and the value ...
tost's user avatar
  • 43
4 votes
4 answers
2k views

I have several processes in which I use System.Random's default constructor to generate random numbers. I read about it on MSDN but it dosn't say the specific system clock resolution it uses, for ...
KaiserJohaan's user avatar
  • 9,290
2 votes
3 answers
401 views

In my .NET game my rand function that are determining how much damage each out of the players five characters should take, however the 1st one always seems to be at the bottom of the scale and the ...
Vlad's user avatar
  • 1,797
1 vote
2 answers
3k views

I'm writing some N-Unit tests and I'm having a little difficulty. I'm trying to wire up a Test to a TestCaseSource in my code, but it doesn't seem to be constructing the objects correctly. Here is my ...
elucid8's user avatar
  • 1,432
5 votes
4 answers
180 views

For example, if I have a class: public class Class { public Random r; public Class() {r= new Random()} } and later create two instances of it: Class a = new Class(); Class b = new Class(); and call ...
user794479's user avatar
1 vote
2 answers
2k views

I am creating a unit test that will test company information into the system but so I can test various assertions in my test. Here is the code I wrote: public static Random randnum = new Random(); ...
CSharpDev4Evr's user avatar
1 vote
4 answers
1k views

I'm learning C# and I'm currently playing with Monogame. What I'm trying to do is declare a public instance of the System.Random class called "randVar" in my Game1 class and then access it from my ...
Scott's user avatar
  • 385
0 votes
1 answer
1k views

I've written some code, it's just an experiment. I had an idea (probably has been done before) to create a random image and set pixels rgb values at random locations to an ascii character number in ...
user2864613's user avatar
1 vote
2 answers
166 views

I have the following C# code which fills an ArrayList with Random numbers between 1 to 30. I have to call this function 25 times. My code: private void getNextTrack() { int ...
Chuker's user avatar
  • 123
1 vote
2 answers
718 views

So I'm building a small math game where random sums are generated and, upon being answered, added to either a right or wrong score. It's going well, and I've received some help with certain things and ...
Mango's user avatar
  • 91
3 votes
1 answer
285 views

I know there are many thread-safety questions especially regarding the Random class in VB.NET and C#. I've read through several as well as a blog post from Jon Skeet (https://codeblog.jonskeet.uk/2009/...
philomathic_life's user avatar

15 30 50 per page