Click here to Skip to main content
15,889,200 members
Articles / Programming Languages / C#

How to Generate Many Random Various Numbers?

Rate me:
Please Sign up or sign in to vote.
4.94/5 (26 votes)
28 Jan 2011CPOL 71.9K   18  
How to generate many random various numbers?

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
6 Sep 2011Luc Pattyn
This is an alternative to "How to Generate Many Random Various Numbers?"
Please Sign up or sign in to vote.
9 Sep 2011myker
Use LINQ:public IEnumerable GenerateRandomSequence(int min, int max){ var rnd = new Random(); return Enumerable.Range( min, max-min ).OrderBy( n => rnd.Next() );}You'll need a reference to System.Core to use this, and a version of .NET that supports LINQ.If you're using...
Please Sign up or sign in to vote.
12 Sep 2011kribo
Found this little peace of code in book and kept it.using System.Security.Cryptography;public static int RandomNumber(int maxvalue){ RandomGenerator random = RandomGenerator.Create(); byte[] r = new byte[1]; random.GetBytes(r); double val = (double)r[0]/byte.MaxValue; ...

License

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


Written By
Software Developer (Senior)
Iran (Islamic Republic of) Iran (Islamic Republic of)
Microsoft Certified Technology Specialist (MCTS)


"شاهین خورشیدنیا"


Nobody is perfect and neither am I, but I am trying to be more professional. In my humble opinion, you have to develop your skills, as long as you are responsible for developing even a tiny part of a sustainable software. That makes this job so special to me.

Comments and Discussions