C # Verification Code

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.