jeudi 17 septembre 2015

How to get all variables declared in a method scope

Is there any way to get all variables declared in a method and parameters received?

I am trying to get all the variables and its values in a method which I want to add to logs. I could get the parameters received in the method defnition using MethodBase.GetCurrentMethod().GetParameters(). That too has one drawback I noticed that, I have to explicitly pass something specific to the method in order to take the value of the parameter.

What I want is, I want all the variables and its values declared in a method scope in a general way, without explicitly giving any method specific parameters(since I want to add the same logic to several method). Any one please have your thoughts.

Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire