C#?????????throw????????
???????????? ???????[ 2014/5/12 13:55:25 ] ??????????????? net ????
????Exception??????
????????Exception?????????????SystemException??ApplicationException?????????????????????????????????????????е???
???????????????Demo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace finallyReturn
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("??????1~4????");
try
{
int num = int.Parse(Console.ReadLine());
if (num < 1 || num > 4)
throw new MyException("???????Χ??");
}
catch (MyException me)
{
Console.WriteLine(me.Message);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.WriteLine("????Finally??");
}
Console.ReadLine();
return;
}
}
class MyException : ApplicationException
{
//public MyException(){}
public MyException(string message) : base(message) { }
public override string Message
{
get
{
return base.Message;
}
}
}
}
|
?????????????????????MyException??ApplicationException??catch??MyException me??????????????????catch??Exception e????????????????????????????catch????????????catch????????У???????finally?е????
??????

???·???
App??С????H5?????????????????Щ??
2024/9/11 15:34:34?????????????????????????
2024/9/10 11:13:49P-One ???????????????????????????????????????
2024/9/10 10:14:12???????????????????????????
2024/9/9 18:04:26??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44