I need to identify the overloaded constructor to pass the values using reflection .The Partial code is :
asm=Assembly.Load("RulesLibrary");
Type t = asm.GetType("RulesLibrary.MedicalInsuranceRules");
object ActObj = Activator.CreateInstance(t);
object[] conparam = new object[2];
conparam[0] = "RuleID"; // string
conparam[1] =12; // int
// How to find out the overloaded constructor in Type MedicalInsuranceRules
ConstructorInfo cinfo = t.GetConstructor();
cinfo.Invoke(ActObj, conparam);
Suppose the type MedicalInsuranceRules contains overloaded constructors
public MedicalInsuranceRules( ){}
public MedicalInsuranceRules(string ruleID,int subSection ){}
public MedicalInsuranceRules(string ruleID,
int subSection,string majorDocID ){}
How can i match the excat contructor during reflection ?
Best Solution
Type.GetConstructor has an overload where you can specify the types of the constructor arguments e.g.