如何獲取作爲參數傳遞給方法的原始屬性名稱的名稱?從方法參數獲取原始屬性名稱
class TestA
{
public string Foo { get; set; }
public TestA()
{
Foo = "Bar";
TestB.RegisterString(Foo);
}
}
class TestB
{
public static void RegisterString(string inputString)
{
// Here I want to receive the property name that was used
// to assign the parameter input string
// I want to get the property name "Foo"
}
}
不可能。你爲什麼需要它? –
我想實現一些自動註冊命令的同名。 :/ –