Invoking methods with optional parameters through reflection
I've run into another problem using C# 4.0 with optional parameters. How do I invoke a function (or rather a constructor, I have the ConstructorInfo object) for which I know it doesn't require any parameters? Here is the code I use now: type.GetParameterlessConstructor() .Invoke(BindingFlags.OptionalParamBinding | BindingFlags.InvokeMethod | BindingFlags.CreateInstance, null, new object[0], CultureInfo.InvariantCulture); (I've just tried with different BindingFlags ). GetParameterlessConstructor is a custom extension method I wrote for Type . According to MSDN , to use the default parameter