获取参数的名称传递给方法 [英] Getting the name of the parameter passed into a method

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

问题描述

重复:
http://stackoverflow.com/questions/742350/determine-the-name-of-the-variable-used-as-a-parameter-to-a-method



有什么方法来检索与传递到方法如

  INT someParameter = 1; 
法(someParameter);

公共无效方法(INT参数)
{
//我想'参数',这将是someParameter'的名字。
}


解决方案

没有。这是唯一的的值传递中作为参数的。所有获取方法是整数。该表达式碰巧只是评估变量是未知的,只要你的方法而言的事实。


Duplicate: http://stackoverflow.com/questions/742350/determine-the-name-of-the-variable-used-as-a-parameter-to-a-method

Is there any way to retrieve the name of a parameter that was passed into a method e.g.

int someParameter = 1;
Method(someParameter);

public void Method(int parameter)
{
    // I want the name of 'parameter' which will be 'someParameter'.
}

解决方案

No. It's only the value which is passed in as the argument. All the method gets is the integer. The fact that the expression happened to be just evaluating a variable is unknown as far as your method is concerned.

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

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