You do not need to pass constructorInfo as a parameter as soon as you call the constructor, but not the object instance method.
var constructorInfo = typeof(Program).GetConstructor( new[] { typeof(int), typeof(int), typeof(int) }); if (constructorInfo != null) { object[] lobject = new object[] { 1, 2, 3 }; constructorInfo.Invoke(lobject); }
For KeyValuePair<T,U> :
public Program(KeyValuePair<int, string> p) { Console.WriteLine(string.Format("{0}:\t{1}", p.Key, p.Value)); } static void Main(string[] args) { var constructorInfo = typeof(Program).GetConstructor( new[] { typeof(KeyValuePair<int, string>) }); if (constructorInfo != null) { constructorInfo.Invoke( new object[] { new KeyValuePair<int, string>(1, "value for key 1") }); } Console.ReadLine(); }
source share