有没有一种方法可以组合Enum中的标志,但限制可能的组合? 我有一个枚举这样的:限制标志的可能组合
[Flags]
public enum CopyFlags
{
/// <summary>
/// Copy members regardless of their actual case
/// </summary>
CaseSensitive = 1,
/// <summary>
/// Indicates if a leading underscore (e.g. _myMember) should be ignored while comparing member-names.
/// </summary>
IgnoreLeadingUnderscore = 2,
/// <summary>
/// Indicates if only properties should be copied. Usefull when all technical data is stored in properties.
/// </summary>
PropertiesOnly = 4
}
现在我也想引进FieldsOnly
- 值,但确保它只是用来当PropertiesOnly
不存在。这可能吗?
不,没有什么可以防止这种情况。即使'(CopyFlags)12345'也是有效的。 – leppie 2014-08-28 13:03:36