Throw:
Thrown exception is an object whose class is derived from System.Exception
When an exception is thrown, program looks for the catch statement that handles the exception
Code Listing: Throw
using System;
public class ThrowTest
{
public static void Main()
{
string s = null;
if (s == null)
{
throw(new ArgumentNullException());
}
Console.Write("The string s is null"); // not executed
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment