Hi,
If you're writing a tracing and logging component you may well want to pass
the current method name to your logging component. Rather than hard code it
(then forget to change it when you change the method name) you can use
reflection and the MethodBase class to retrieve the name.
System.Reflection.MethodBase currentMethod =
System.Reflection.MethodBase.GetCurrentMethod();
System.Diagnostics.Debug.WriteLine(currentMethod.N ame);
System.Diagnostics.Debug.WriteLine(currentMethod.D eclaringType.Name);
System.Diagnostics.Debug.WriteLine(currentMethod.D eclaringType.Namespace);
ref:
http://idunno.org/archive/2004/12/03/163.aspx
--
Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
"Vikram" wrote:
is there any object available in c#/asp.net which can give me event name in
that eevnt only. Like if I am in Page_load event, i should get Page_Load or
if I am in Button_click event I should get Button_Click. SO that I can logg
it in my cutom log file with a generic logic.
Thanks