March 2004
Intermediate to advanced
560 pages
26h 47m
English
The following example demonstrates catching an exception type that derives from ApplicationException. There is, however, no valid scenerio for catching an ApplicationException type.
using System;
using System.Reflection;
namespace Samples
{
public class ApplicationExceptionSample
{
public static void Main()
{
try
{
Type t = typeof(string);
MethodInfo m = t.GetMethod("EndsWith");
string s = "Hello world!";
object[] arguments = {"world!", "!"};
Console.WriteLine(m.Invoke(s, arguments));
}
catch(ApplicationException e)
{
Console.WriteLine("Exception: {0}", e);
}
}
}
}
Exception: System.Reflection.TargetParameterCountException: Parameter count mismatch. at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags ...
Read now
Unlock full access