usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceVerification Code string procedure {classProgram {Static voidMain (string[] args) { //defines a set of string codes that require 26 English-case and 0~9 numbers string[] s=New string[ +] {"0","1","2","3","4","5","6","7","8","9", "a","b","C","D","e","F","g","h","I","J","k","L","m","N","o","P","Q","R","s", "T","u","v","W","x","y","Z", "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q", "R","S","T","U","V","W","X","Y","Z" }; stringA="";//defines a character variable with a value of NULLRandom ran =NewRandom (); //Initial random number for(inti =0; I <4; i++)//Verification code requires four strings, need to loop four times, one string at a time randomly connected to the verification code {intSuijishu = ran. Next ( +); The //array has 62 strings, creating a random number within 62, used to index a string within a random array + = S[suijishu];//Four randomly generated characters are linked to a string representing the verification code} Console.WriteLine ("Verification Code:"+a); stringb = A.toupper ();//background execution Converts the output string all to uppercaseConsole.Write ("Please enter the verification code:"); stringR =Console.ReadLine (); stringQ = R.toupper ();//converts a user-entered string all to uppercase so that it is compared to the output string if(q = =b) //If the user enters the same as the computer output, the validation succeeds {Console.WriteLine ("Verify Success! "); } Else//If it is not the same, the input error, external can also add an infinite loop, when the input error, re-input, success if the following break jump{Console.WriteLine ("input Error! "); } console.readline (); } }}
C # Verification Code