Nev*_*lle 1 .net c# exception-handling exception
我有这个简单的程序演示.NET中的异常处理,我ArgumentOutOfRangeException
在这种情况下捕获,但我传递给控制台的自定义消息没有显示.
using System;
class program
{
static void Main()
{
int[] source = { 1, 2, 3, 4, 5 };
int[] destination = { 6, 7, 8, 9 };
try
{
Array.Copy(source, destination, 7);
}
catch (ArgumentOutOfRangeException e)
{
Console.WriteLine("Sorry, there is something wrong in the program ! : {0}", e.Message);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是输出截图