从方法内部获取方法的参数名称和值 [英] Get method's parameters names and values from inside method

查看:343
本文介绍了从方法内部获取方法的参数名称和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET中是否有一种方法可以知道将哪些参数及其值传递给方法。反射方式?这将在方法内部使用。它必须是通用的,因此可以从任何方法使用。

Is there a way in .NET to know what parameters and their values were passed to a method. Reflection way? This will be used from inside the method. It has to be generic so it can be used from any method. This is for logging purposes.

推荐答案

MethodInfo.GetCurrentMethod() 将为您提供有关当前方法的信息,然后使用 GetParameters获取有关参数的信息()

这篇关于从方法内部获取方法的参数名称和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆