March 2004
Intermediate to advanced
560 pages
26h 47m
English
The following example demonstrates catching an exception type that derives from SystemException. There is, however, no valid scenario for catching a SystemException type.
using System;
namespace Samples
{
public class SystemExceptionSample
{
public static void Main()
{
try
{
string s = null;
Console.WriteLine(s.ToString());
}
catch(SystemException e)
{
Console.WriteLine("Exception: {0}", e);
}
}
}
}
Exception: System.NullReferenceException: Object reference not set to an instance of an object. at Samples.SystemExceptionSample.Main() in C:\Books\BCL\Samples\System\ SystemException\SystemException.cs:line 12
Read now
Unlock full access