编辑代码

using System;
using System.Collections.Generic;

class CustomException : Exception
{
    public CustomException(string message)
    {
    }
    }
}

public class HelloWorld
{
    public static void Main()
    {
        try
        {
            TestThrow();
        }
        catch (CustomException ex)
        {
            System.Console.WriteLine(ex.ToString());
        }
    }

    private static void TestThrow()
    {
        throw new CustomException("Custom exception in TestThrow()");
    }
}