ToString is superior than Message. Very useful for debugging purposes!
using System;
using System.Collections.Generic;
using System.Text;
namespace ExceptionToString
{
public class MyClass {}
public class ArgExceptionExample
{
static void Main(string[] args)
{
MyClass my = new MyClass();
string s = "sometext";
try
{
int i = s.CompareTo(my);
}
catch (Exception ex)
{
Console.WriteLine("Error: {0}\n", ex.ToString());
Console.WriteLine("Error: {0}", ex.Message);
Console.Read();
}
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment