1
我有這個簡單的程序演示了.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);
}
}
}
,這裏是輸出截圖
我編輯了你的標題。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –