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 and I know it doesn't require any parameters, but I still can't invoke it.
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 ExtensionMethod I wrote for Type
.