sno*_*oop 1 c# methods invoke nullreferenceexception winforms
我想从字符串中调用一个方法,但它不允许我null作为参数传递.该方法不需要参数.
private void reconnect_Click(object sender, EventArgs e)
{
string methodName = "data_load1";
//Get the method information using the method info class
MethodInfo mi = this.GetType().GetMethod(methodName);
//Invoke the method
mi.Invoke(this, null);
}
Run Code Online (Sandbox Code Playgroud)
data_load方法:
private void data_load1()
{
this.dataTableAdapter.Fill(this.myDataSet.data);
}
Run Code Online (Sandbox Code Playgroud)
我收到NullReferenceException was unhandled了mi.Invoke(this, null);.为什么这不让我传递null参数?