如何获得信息参数值? [英] How to get ParameterInfo Value?

查看:241
本文介绍了如何获得信息参数值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是低于code得到调用方法的名称和它的一个方法中的参数。

I am using the below code to get Calling Method name and its parameter inside a method.

var stackTrace = new StackTrace();
var methodName = stackTrace.GetFrame(1).GetMethod().Name;
var parameters = stackTrace.GetFrame(1).GetMethod().GetParameters();

foreach (var parameterInfo in parameters)
{
    var name = parameterInfo.Name;
    var value = "How to get value?";
}

现在我的问题是,以获取参数的值。
任何想法?

Now my question is to get the value of that parameter. Any ideas?

推荐答案

简短的回答是,你不能。

The short answer is that you can't.

但如果你真的坚持这样做的有一些方法多数民众赞成相当复杂。一个已经读到这里
怎么得到的堆栈跟踪参数值

But if you really insist on doing it there are some ways thats quite more complicated. have a read here How get value of parameters in stacktrace

这篇关于如何获得信息参数值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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