Accessing Exception Object Properties C# with Example



Accessing Exception Object Properties C# with Example

 	using System;

	namespace CSharpExceptionHandling
	{
		class ExceptionBasics
		{
			static void Main(String[] arg)
			{
				int x=10, y=0;
				try
				{
					x /= y;
					Console.WriteLine("X: " + x);
				}
				catch(Exception exp)
				{
					Console.WriteLine("Message: " + exp.Message);
					Console.WriteLine("Source: " + exp.Source);
					Console.WriteLine("StackTrace: " + exp.StackTrace);
					Console.WriteLine("Data: " + exp.Data);
					Console.WriteLine("InnerException: " + exp.InnerException);
				}
			}
		}
	}
 

0 Comment's

Comment Form