有沒有一種方法可以組合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