Verify that the input meets the criteria

Source: Internet
Author: User

Break jumps out of the loop closest to it. such as while, for

Verify that the five letters you entered are uppercase.

 Public Static voidMain (string[] args) {Console.WriteLine ("Please enter five uppercase letters:");  while(true) {//Loop until it is entered correctly                BOOLA =true; stringstr =console.readline ();//The input defaults to a string.                If the data is int, then Convert.ToInt32 (str);  for(inti =0; I <5; i++) {                    if(Str[i] >='A'&& Str[i] <='Z') {//characters are stored as int data, character equivalent data//empty statement, no action}Else{a=false;  Break;//Once there is a lowercase letter, jump out of the For Loop                    }                }                if(A = =true) {Console.WriteLine ("Enter the correct");  Break;//Jump out while loop}Else{Console.WriteLine ("have lowercase letters, input errors, please re-enter");        }} console.readkey (); }

Verify that the input meets the criteria

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.