First of all: I am using C++-CLI, but I would like to know the solution for C# as well.
Using following code
assembly "basics"
public ref class CONSTS abstract sealed
{
public:
static const int SUCCESS = 1;
static const int InProgress = 101;
};
assembly "program"
enum class EnumReplyLLI
{
Nothing = 0,
SUCCESS = CONSTS::SUCCESS, // C2057
Busy = CONSTS::InProgress, // C2057
...
};
I get the error C2057: expected constant expression
How can I define a compile-time constant and use it in another assembly?
My code is almost identical to the accepted answer in this SO post, but this does not work.