This C# program will help you to catch C# ArgumentException. As you can see that the function accepting the object type while we are passing int type.
using System;
namespace MyApp
{
class ArgumentException_class
{
public static void Main(string[] args)
{
try
{
string strException = "C# ArgumentException Example";
strException.CompareTo(123);
}
catch (ArgumentException ex)
{
Console.WriteLine("Exception: {0}", ex.Message);
}
Console.Read();
}
}
}
No comments:
Post a Comment