feyris-tan ef86554f9a Import
2025-05-12 22:09:16 +02:00

25 lines
569 B
C#

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)));
}
}
}