c# - 获取传递给方法的参数的名称

标签 c# reflection parameters

<分区>

重复: Determine the name of the variable used as a parameter to a method

有什么方法可以检索传递给方法的参数的名称,例如

int someParameter = 1;
Method(someParameter);

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

最佳答案

没有。它只是作为参数传入的。所有方法获取的都是整数。就您的方法而言,表达式恰好只是评估变量这一事实是未知的。

关于c# - 获取传递给方法的参数的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/755254/

相关文章:

c# - 如何遍历 WPF 工具包 Datagrid 的行

c# - EF Core 2.0 - 包含和 ThenInclude : child collection -- grandchild collection

spring - Spring 如何在没有调试信息的情况下获取参数名称

powershell - 脚本中的代码有所不同,具体取决于从另一个脚本或shell调用

windows - 批处理脚本传递多个参数调用

c# - javascript 警报无法在 Razor 代码中显示其消息

c# - 在 VS2010 Express 中创建构造函数的代码片段

c# - 使用反射为单元测试做复杂的对象断言是不好的做法吗?

python - "Too few parameters"IN 条件值列表错误

parameters - 如何将 alpha(透明度)传递给 seaborn.jointplot?