I have a similar problem the issue described in this SO question
In my case however the optional param default values is:
1. Defined in a separate C++/CLI dll.
2. Is already defined in that lib as "public static const"
When I try to use the value as a default parameter value from C# I get "must be a compile time constant".
Is there a way to share a common const value between (C++/cli) library and (C#) app?
C++/CLI lib:
namespace MyCPlusPlusCLILib {
public ref class CPPCLIClass {
public:
static const double Invalid = -1;
}
C# code:
public MyMethod(double fish = MyCPlusPlusCLILib.CPPCLIClass.Invalid) { }
// C# compiler error "Must be a compile time const"
OR
const double MyConstDouble = MyCPlusPlusCLILib.CPPCLIClass.Invalid;
// C# compiler error "Must be a compile time const"