我正在尝试做这样的事情:
public class MyClass()
{
private void SetAValiable(int boolNumber)
{
bool b1 = false;
bool b2 = false;
("b" + boolNumber) = true;
}
}
Run Code Online (Sandbox Code Playgroud)
我试过这个但是不断从GetProperty调用中得到一个null:
Type myType = typeof(MyClass);
PropertyInfo pinfo = myType.GetProperty("b" + boolNumber);
pinfo.SetValue(myType, true, null);
Run Code Online (Sandbox Code Playgroud)
任何人都有任何想法如何让这个工作?
谢谢!