Created
April 12, 2018 19:59
-
-
Save Flayed/0b0a7e3cdb95814ed2bf6c3bf48e9e1b to your computer and use it in GitHub Desktop.
Packing Bytes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum DayOfWeek | |
{ | |
Sunday = 0, | |
Monday = 1, | |
Tuesday = 2, | |
Wednesday = 3, | |
Thursday = 4, | |
Friday = 5, | |
Saturday = 6 | |
} | |
private byte PackedDays { get; set; } | |
public DayOfWeek StartDay | |
{ | |
get { return (DayOfWeek)(PackedDays & 15); } | |
set { PackedDays |= (byte)value; } | |
} | |
[BsonIgnore] | |
public DayOfWeek EndDay | |
{ | |
get { return (DayOfWeek)(PackedDays >> 4); } | |
set { PackedDays |= (byte)((byte)value << 4); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment