Random number Classes
Random ran = new random ();//initialization
Double A = ran. Next (10);
int B = ran. Next (s.length);
Console.WriteLine (a);
Practice
Random verification Code, control the input, determine whether the correct
string s = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789";
Random ran = new random ();
String Biao = "";
for (int i = 1; I <= 4; i++)
{
Biao + = S.substring (ran. Next (s.length), 1);
}
Console.WriteLine (Biao);
Console.Write ("Please enter the Verification Code:");
String shu = Console.ReadLine ();
if (Shu. ToLower () = = Biao. ToLower ())
{
Console.WriteLine ("Input Correct! ");
}
Else
{
Console.WriteLine ("Input Error! ");
}
Console.ReadLine ();
Console.clear ();
Console.WriteLine ("123");
Enter the verification code
string s = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";
Random ran = new random ();
for (;;)
{
string a = "";
for (int i = 1; i < = 4; i++)
{
A + = S.substring (ran. Next (s.length), 1);
}
Console.WriteLine (a);
Console.WriteLine ("Please enter the Verification Code:");
String B = Console.ReadLine ();
if (b.tolower () = = A.tolower ())
{
Console.WriteLine ("Input correct");
Break
}
Else
{
Console.clear ();
Console.WriteLine ("Input Error");
}
}
Random Number Class