反射GET变量的方法 [英] Reflection Get Variables in Method

查看:101
本文介绍了反射GET变量的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能得到方法使用可变因素,然后我会写他们的控制台值?

How can i get varibles used in Method which then I will write their values on Console ?

推荐答案

您不能。反射没有延伸到的阅读的方法变量的值。它只处理的声明的变量的元数据。即使如此,编译器可能已经删除,你以为你声明的变量。反射允许完全访问的字段的(例如/静态类型变量),而不是方法变量。

You cannot. Reflection does not extend to reading the values of method variables. It only handles the declaration metadata of variables. And even then, the compiler may have removed the variable you thought you declared. Reflection allows full access to fields (instance / static type variables), but not method variables.

有,你可以像使用lambda表达式的招数,但这改变其形式(从方法变量为实例字段)。

There are tricks you can use like lambda expressions, but this changes their form (from method variables into instance fields).

这篇关于反射GET变量的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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