Print class name, method name for debugging purpose c#

c#

– For normal purpose:
Debug.WriteLine(this.GetType().Name + " - " + MethodBase.GetCurrentMethod() + " - " + e.Message + " - " + e.GetType());
– For catching an exception:
Debug.WriteLine(this.GetType().Name + " - " + MethodBase.GetCurrentMethod() + " - " + e.Message + " - " + e.GetType());

Explaination:
this.GetType().Name : will print the calling class.

About: tientham

Software Engineer, SW Integrator & Mobile , Full Stack Developer


Leave a Reply

Your email address will not be published. Required fields are marked *