Reputation: 1
I create application win forms, where after submit the all detail generates random number and string. after generating random number then save it in SQL database. so tell me how to generate combination of random number and random string.
Upvotes: 0
Views: 640
Reputation: 18649
Use DateTime.Now.Ticks.ToString()
or DateTime.Now.ToFileTime().ToString()
to generate random number.
Upvotes: 0
Reputation: 1082
Here
using System;
using System.Text;
public string RandomString (Random r, int len)
{
string str
= "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
StringBuilder sb = new StringBuilder();
while ((len--)> 0)
sb.Append(str[(int)(r.NextDouble() * str.Length)]);
return sb.ToString();
}
Upvotes: 0