C # Notes (v)--loop structure

Source: Internet
Author: User

Define a variable to record the number of laps, loop variable initialization   int i = 0;//execution loop condition i.e. cyclic condition  while (i < Ten)  { console.writeline ("Run" + i);  i++;//i is the cyclic variable//condition is becoming more and more unsatisfied, eventually jumping out of the loop}//for (cyclic variable initialization; condition judgment; cyclic variable change) {//Loop body}console.writeline ("{0,2}", i), front 2 spaces,- 2 after two spaces (left justified)//outer row number, inner layer is the contents of the row for (int j = 1; j < 4; j + +)           & nbsp {                for (int i = 1; i < 4; I + +)                 {                     Console. Write ("{0,-2}", i);               }                 Console. WriteLine ();           }/99 multiplication table for (int i = 1; I < = 9; i++)             {                 for (int j = 1; J <= I; j + +)      & nbsp;          {                     Console. Write ("{0}*{1}={2,-3}", J, I,i*j);                }                Console . WriteLine ();           }             Console. ReadKey ();Circular Summary:for most common, usually used to know the loop of the number of loopsWhile is also very common, often used for loops that do not know the number of loopsDo......while is not very common and is typically used for loops that need to be executed first.Break jumps out of this layer loop, continue ends the loop, usually with ifthe variable defined in for () is used only in the loop body {}.

C # Notes (v)--loop structure

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.