C#入门记录10

异常处理

直接上代码

/*
2020年3月7日15:42:33
异常处理
try...catch语句

*/
using System;

namespace ConsoleApp10
{
    class Program
    {
        static void Main(string[] args)
        {

            testError();


            Console.ReadKey();
            //Console.WriteLine("Hello World!");
        }

        static void testError()
        {
            try
            {
                int num1 = 5;
                int num2 = 0;
                int result = num1 / num2;
            }
            catch(Exception ex)
            {
                Console.WriteLine("捕获异常:" + ex);
            }
        }
    }
}

到这里为止,关于C#的基本知识点就记录完了,接下来学习窗体部分的知识点;

猜你喜欢

转载自blog.csdn.net/Wuzm_/article/details/104818072