【发布时间】:2016-01-12 14:43:23
【问题描述】:
首先:我正在使用 C++-CLI,但我也想知道 C# 的解决方案。
使用以下代码
组装“基础”
public ref class CONSTS abstract sealed
{
public:
static const int SUCCESS = 1;
static const int InProgress = 101;
};
汇编“程序”
enum class EnumReplyLLI
{
Nothing = 0,
SUCCESS = CONSTS::SUCCESS, // C2057
Busy = CONSTS::InProgress, // C2057
...
};
我收到错误C2057:预期的常量表达式
如何定义编译时常量并在另一个程序集中使用它?
我的代码几乎与this SO post 中接受的答案相同,但这不起作用。
【问题讨论】:
标签: c# c++-cli compile-time-constant