enum ValidationMessages
{
C01_OOHArrestRequired = "Test",
Trivial,
Regular,
Important,
Critical
};
我有上面的代码。我想能够创建我可以使用的枚举,但是不是整数的字符串。枚举为字符串
这是我可以在UI中显示相同的字符串验证错误,然后在我的单元测试中测试它们,并让消息从相同的地方(静态)传出。
但它说:“不能把字符串转换为int”
如何有enum
为字符串?
然后,不要使用枚举。用一堆常量使用一个类。 – Candide
看到这个有趣的问题:http://stackoverflow.com/questions/424366/c-sharp-string-enums –