Enum에 대한 if 조건이 있습니다. 내 열거입니다조건에 if 플래그 사용
public enum EmploymentType
{
Type1 = 1,
Type2 = 2,
Type3 = 3
}
이 조건이 조건
EmploymentType type = EmploymentType.Type1 ;
if (type.HasFlag(EmploymentType.Type1 | EmploymentType.Type2)) //if (type == (EmploymentType.Type1 | EmploymentType.Type2))
{
return true;
}
else
{
return false;
}
예상 진정한 결과,하지만 결과는 false입니다. 왜?
왜'(타입 == EmploymentType.Type1 || 타입 == EmploymentType.Type2)의 경우' –
[Enum Flags Attribute] (http://stackoverflow.com/questions/8447/enum-flags-attribute)를 읽어보십시오. –