Skip to content

Instantly share code, notes, and snippets.

@andreisfedotov
Created December 12, 2018 15:40
Show Gist options
  • Save andreisfedotov/020b941ddb9412dd38d9df6861c2db21 to your computer and use it in GitHub Desktop.
Save andreisfedotov/020b941ddb9412dd38d9df6861c2db21 to your computer and use it in GitHub Desktop.
enum Items : byte
{
DisabledFlag = 1 << 7;
One = 1;
Two = 2;
Three = 5;
}
//=========
[DataMember]
private bool IsDisabled
{
get { return (CODE & (byte) Items.DisabledFlag) > 0; }
set
{
CODE = value
? (byte)(CODE | (byte) Items.DisabledFlag)
: (byte)(CODE & (byte.MaxValue ^ (byte) Items.DisabledFlag));
}
}
[DataMember]
private byte Code
{
get { return (byte)(CODE & (byte.MaxValue ^ (byte) Items.DisabledFlag)); }
set
{
CODE = IsDisabled
? (byte) (value | (byte) Items.DisabledFlag)
: value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment