Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi.
how can i generate n random number between (a) and (b) that are around a number like (x)?

What I have tried:

hi.
how can i generate n random number between (a) and (b) that are around a number like (x)?
Posted
Updated 17-Jun-17 9:07am
v2

Google is your friend, lots of answers and details;

Random random = new Random();
int randomvalue = random.Next(a, b + 1);

What do you mean by "on a number like (x)"?
 
Share this answer
 
Comments
Member 13264936 17-Jun-17 14:47pm    
it means random numbers are around (X)
Michael_Davies 17-Jun-17 14:51pm    
Your definition is that the numbers are between a and b, take it then that x is the mid point between a and b.

Anyhow, lots of documentation on the Random class on MSDN, take a read, experiment and use Google to find what you are looking for.
See this example: [dotnetperls]
 
Share this answer
 
Quote:
how can i generate n random number between (a) and (b) that are around a number like (x)?

C# have random function, first step is to read the documentation.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900