我在C#中有两个枚举
public class PlayerAttributes
{
private UInt32 m_AttributeFlagsMask;
private UInt32 m_AttributeFlagsBitmap;
[Flags]
public enum EAttributesFlagsBmp
{
AIn = 0,
BIn = (1 << 1), //1
CIn = (1 << 2), //2
DIn = (1 << 3), //4
EIn = (1 << 4), //8
FIn = (1 << 5), //16
GIn = (1 << 6) //32
}
[Flags]
public enum EAttributeFlagsMask
{
None = 0,
AIn = (1 << 1), //1
BIn = (1 << 2), //2
CIn = (1 << 3), //4
DIn = (1 << 4), //8
EIn = (1 << 5), //16
FIn = (1 << 6) //32
}
public UInt32 AttributeFlagsMask { get { return m_AttributeFlagsMask; } private set { m_AttributeFlagsMask = value; } }
public UInt32 AttributeFlagsBitmap { get { return m_AttributeFlagsBitmap; } private set { m_AttributeFlagsBitmap = value; } }
public bool SetAIn(bool enable)
{
if(enable)
{
}else
{
unset AIn bit but enable AIn flag
}
return true;
}
}
在功能AIn
中我想unset AIn bit but enable AIn flag
。我该怎么做。我不能在!
上使用UInt32
运算符
答案 0 :(得分:1)
int
上的按位求反运算符为~
:
if (enable) {
m_AttributeFlagsMask |= AIn;
} else {
m_AttributeFlagsMask &= ~AIn;
}