简体   繁体   中英

c# reflection current of runtime parameter values

For some debug code I'm writing Trace code I'm trying to output the name of the method using MethodBase.GetCurrentMethod().ToString() but I also wanted to output the current methods parameter names and values. Is this possible?

You can get the parameter names (and types, modifiers, attributes etc) via MethodBase.GetParameters but you can't get the values that way. You may want to consider using some form of AOP (such as Postsharp ) to add logging for parameter values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM