C# while循环
2021-05-18 14:30
                         标签:控制   mil   sum   死循环   namespace   ima   line   csharp   循环    一、简介 只要给定条件为true,C#的while循环语句会循环重新执行一个目标的语句。 二、语法 C# while的语法: while(循环条件) {      循环体; } 三、执行过程 程序运行到while处,首先判断while所带的小括号内的循环条件是否成立,如果成立的话,也就是返回一个true,则执行循环体,执行完一遍循环体后,再次回到循环条件进行判断,如果依然成立,则继续执行循环体,如果不成立,则跳出while循环体。 在while循环当中,一般总会有那么一行代码,能够改变循环条件,使之终有一天不在成立,如果没有那么一行代码能够改变循环条件,也就是循环体条件永远成立,则我们将称之为死循环。 最简单死循环: while(true) { } 四、特点 先判断,在执行,有可能一遍都不执行。 五、实例 1.向控制台打印100遍,下次考试我一定要细心. 输出结果   2.求1-100之间所有整数的和 输出结果    C# while循环 标签:控制   mil   sum   死循环   namespace   ima   line   csharp   循环    原文地址:https://www.cnblogs.com/qy1234/p/11737323.htmlusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Loops
{
    class Program
    {
        static void Main(string[] args)
        {
            //需要定义一个循环变量用来记录循环的次数,每循环一次,循环变量应该自身加1
            int i = 1;
            while (i

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Loops
{
    class Program
    {
        static void Main(string[] args)
        {
            //求1-100之间所有整数的和
            //循环体:累加的过程
            //循环条件:i
