当前位置:
首页 > Python基础教程 >
-
C#教程之Python3 与 C# 面向对象之~异常相关(2)
:
----> 8raise DntException("num must>0")
9 else:
10 print(num)
DntException: num must>0
%%script csharp
try
{
Convert.ToInt32("mmd");
}
catch (Exception ex)
{
// Input string was not in a correct format
Console.WriteLine(ex.Message);
}
%%script csharp
//抛出自定义异常
try
{
throw new Exception("出错了啊");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}