hai friends,

i want one help, how to generate a random numbers without duplication for more than 60 persons. My project is Online Examination in asp.net code behind c#.net.

please help.

Recommended Answers

All 2 Replies

use the System.Random class in C# its 2 lines of code

Here's what I came up with a while back. You can pass in the length of the string and whether you want to have all lowercase returned.

public static string RandomString(int size, bool lowerCase)
{
   StringBuilder builder = new StringBuilder();
   Random random = new Random();
   char ch ;
   for(int i=0; i<size; i++)
      {
         ch = Convert.ToChar(Convert.ToInt32(26 * random.NextDouble() + 65)) ;
         builder.Append(ch); 
      }
      if(lowerCase)
     return builder.ToString().ToLower();
     return builder.ToString();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.