日期:2014-05-19  浏览次数:20848 次

谁知道这是为什么?
using   System;
using   System.Collections.Generic;
using   System.Text;

namespace   ConsoleApplication2
{
        class   Program
        {
                static   void   Main(string[]   args)
                {
                        int   i;
                        string   text   =   " ";
                        for   (i   =   0;   i   <   10;   i++)
                        {
                                text   =   "Line   "   +   Convert.ToString(i);
                                Console.WriteLine( "{0} ",   text);
                        }
                        Console.WriteLine( "Last   text   output   in   loop:{0} ",text);
                        Console.ReadKey();
                }
        }
}

RT:
为什么结果中text=9了?
麻烦详细介绍下,谢谢

------解决方案--------------------
因为i的循环 最后一次i=9
------解决方案--------------------
当然等于9阿,你i <10的条件不是写着呢么,i=10的时候就不进来了啊,总共进行10次循环
从0到9
最后打印出来的就是9