Home > Net >  Parameter count does not match
Parameter count does not match

Time:05-21

GetCustomerByName writing methods, through reflection executes prompt "argument count does not match",
Is spread and is there a problem? But it's ok to pass only one,

1. Write pass parameters:
String a="as";
String b="bs";
Var result=ExecuteQuery (action, the new object [] {a, b}, ref errMsg);

2. The reflection is called
Public object ExecuteQuery (string methodName, object [] param, ref string errMsg, int timeOut=3000)
{
.
MethodInfo mi=this. _typeName. GetMethod (methodName);
Var rtnObj=mi. Invoke (Instance, param);//the argument count does not match the
}


3. The method called
Public string GetCustomerByName (object [] args) {
String customerName=string. The Empty;
CustomerName=args [0] + ", "+ args [1].
Return customerName.
}
  •  Tags:  
  • C#
  • Related