下面是我的代码中可用的enum
类,但是,我想为它添加一个空值。将空值添加到此类后,我收到错误。
public enum AgentLevel : int
{
[System.Runtime.Serialization.EnumMemberAttribute()]
Location = 1,
[System.Runtime.Serialization.EnumMemberAttribute(Value="Head Quarter")]
HeadQuarter = 2,
}
答案 0 :(得分:2)
如果您只需要初始化一个空字符串,那么您可以:
public enum AgentLevel : int {
[System.Runtime.Serialization.EnumMemberAttribute(Value = "")]
Location = 1,
[System.Runtime.Serialization.EnumMemberAttribute(Value="Head Quarter")]
HeadQuarter = 2,
}