首页 > 其他 > 详细

for ..break和try ..catch

时间:2015-06-18 16:52:17      阅读:236      评论:0      收藏:0      [点我收藏+]
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");
            }

            }*/
        }
    }
}

 

for ..break和try ..catch

原文:http://www.cnblogs.com/qixinjian/p/4586120.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!