How can I declare a managed method in C++/CLI that has an optional parameter when used from C#?
I\'ve decorated the parameter with both an Optional and a DefaultPara
The C# compiler doesn't use the [DefaultParameterValue] attribute to set the default value, it uses the .param directive to get the value embedded in the metadata. Barely documented in the CLI spec btw, only Partition II, chapter 15.4.1 mentions that it can have a FieldInit value, 15.4.1.4 is silent about it.
That's where the buck stops, the C++/CLI compiler doesn't know how to generate the directive. You cannot make this work.