using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace skyscraper5.DNS.Protocol.Utils { internal static class ByteExtensions { public static byte GetBitValueAt(this byte b, byte offset, byte length) { return (byte)((b >> offset) & ~(0xff << length)); } public static byte SetBitValueAt(this byte b, byte offset, byte length, byte value) { int mask = ~(0xff << length); value = (byte)(value & mask); return (byte)((value << offset) | (b & ~(mask << offset))); } } }