Just Copy and paste the Code.
public static string GenerateRandomNumber(int Length)
{
string _allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789";
Random randNumber = new Random();
char[] chars = new char[Length];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i <= Length - 1; i++)
{
chars[i] = _allowedChars[Convert.ToInt32((_allowedChars.Length) * randNumber.NextDouble())];
}
return new string(chars);
}
protected void Button2_Click(object sender, EventArgs e)
{
try
{
string num = GenerateRandomNumber(5);
Label1.Text = num;
}
catch
{
}
}
Click Here For Demo
public static string GenerateRandomNumber(int Length)
{
string _allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789";
Random randNumber = new Random();
char[] chars = new char[Length];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i <= Length - 1; i++)
{
chars[i] = _allowedChars[Convert.ToInt32((_allowedChars.Length) * randNumber.NextDouble())];
}
return new string(chars);
}
protected void Button2_Click(object sender, EventArgs e)
{
try
{
string num = GenerateRandomNumber(5);
Label1.Text = num;
}
catch
{
}
}
Click Here For Demo
No comments:
Post a Comment