⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex-11-02

📁 Programming Csharp Source Code(代码) Programming Csharp Source Code
💻
字号:
// Example 11-02: Catching an exception

namespace Programming_CSharp
{
    using System;

    public class Test
    {
        public static void Main()
        {
            Console.WriteLine("Enter Main...");
            Test t = new Test();
            t.Func1();
            Console.WriteLine("Exit Main...");           

        }

        public void Func1()
        {
            Console.WriteLine("Enter Func1...");
            Func2();
            Console.WriteLine("Exit Func1...");           
        }

        public void Func2()
        {
            Console.WriteLine("Enter Func2...");
            try
            {
                Console.WriteLine("Entering try block...");
                throw new System.Exception();                
                Console.WriteLine("Exiting try block...");
            }
            catch
            {
                Console.WriteLine(
                  "Exception caught and handled.");
            }
            Console.WriteLine("Exit Func2...");
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -