Posts Tagged create

Creating a random number string

Posted by Ozer Senturk on Tuesday, 9 March, 2010
/// <summary>
/// Creates a random number string of length length
/// </summary>
/// <param name="length">The length of the string to be generated</param>
/// <returns>A random number string of length length</returns>
public static string createRandomNumberString(int length)
{
    string result;
    Random random = new Random(DateTime.Now.Millisecond);
    for (result = ""; result.Length < length; result += random.Next(0, 9)) ;
    return result;
}