我有这个功能。
public void AddVariable(String str)
{
Response.Write(str); // will write the value of str
}
但我需要写入传递给函数的字符串变量的名称。
例如:
String temp = "test Variable";
AddVariable(temp);
在这里,我需要得到名字我的函数内部变量的,而不是值。
即,我需要'temp'在我的函数内,而不是'测试变量'。
这是可能吗?
@rs,我试过这个答案,但是我只能得到'str'这个变量的名字,而不是我在 –
@AkhilSekharan中通过的那个:看到这篇文章http://stackoverflow.com/questions/214086/如何获得方法名称参数-in -c –
@pRosper K,它返回参数名称,而不是传入的字符串的名称。:( –