本文介绍了枚举是否以0或1开头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
想象一下,我已经定义了以下枚举:
Imagine I have defined the following Enum:
public enum Status : byte
{
Inactive = 1,
Active = 2,
}
最佳做法是什么使用枚举?如果以上述示例开头,或者从 0开始
1
(不带显式值):
What's the best practice to use enum? Should it start with
1
like the above example or start with 0
(without the explicit values) like this:
public enum Status : byte
{
Inactive,
Active
}
推荐答案
避免使用标志枚举对正负的成员或
为零。 ..枚举值为零会产生和
操作等问题
Avoid using flag enum values normal members that are negative or zero. .. An enum value of zero creates problems with and operations, etc
这篇关于枚举是否以0或1开头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!