for ..break和try ..catch

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
              /*  for (int i = 1; i <= 100; i++)
            {
                Console.WriteLine("hello"+i);
                if (i == 40)
                {
                    break;//终止离它最近的循环,跳出整个循环
                }
            }*/
            /*while (true)
            { string s=Console.ReadLine();
            try//尝试,保护起来,即使程序也能执行出错
            {
                int a = int.Parse(s);
                Console.WriteLine(a);
            }
            catch (Exception b)//捕获错误,有错误才执行
            {
                Console.WriteLine(b);
            }
            finally//不管有没有错最后都执行
            { 
            Console.WriteLine("hello");
            }

            }*/
        }
    }
}

 

posted @ 2015-06-18 16:07  蓝瑟黄昏  阅读(339)  评论(0编辑  收藏  举报