Class ByteExtensions
- Namespace
- Plugin.BaseTypeExtensions
- Assembly
- Plugin.BaseTypeExtensions.dll
Utility method for bytes and byte-arrays.
public static class ByteExtensions
- Inheritance
-
ByteExtensions
- Inherited Members
Methods
GetLowerNibbleBitsAsNewByte(byte)
Creates a new byte from the given byte which has its upper nibble zeroed out. For example passing a byte such as 01010110 will generate a new byte 00000110.
public static byte GetLowerNibbleBitsAsNewByte(this byte b)
Parameters
b
byteThe byte to operate upon.
Returns
- byte
A new byte which is a copy of the given byte but with its upper nibble zeroed out.
GetUpperNibbleBitsAsNewByte(byte)
Creates a new byte from the given byte which has its upper nibble zeroed out while its lower nibble is identical to the upper nibble of the given byte. For example passing a byte such as 0101_0110 will generate a new byte 0000_0101.
public static byte GetUpperNibbleBitsAsNewByte(this byte b)
Parameters
b
byteThe byte to operate upon.
Returns
- byte
A new byte which is a copy of the given byte but with its upper nibble zeroed out and the lower nibble identical to the upper nibble of the given byte.
KeepOnlyUpperNibbleBits(byte)
Creates a new byte from the given byte which has its lower nibble zeroed out. For example passing a byte such as 01010110 will generate a new byte 01010000.
public static byte KeepOnlyUpperNibbleBits(this byte b)
Parameters
b
byteThe byte to operate upon.
Returns
- byte
A new byte which is a copy of the given byte but with its lower nibble zeroed out.
ToBitsString(byte)
Converts a byte to its bit-string representation. For example '15' -> '00001111'
public static string ToBitsString(this byte b)
Parameters
b
byteThe byte to convert
Returns
- string
The bits-string representation
ToReversedByte(byte)
Reverses the bits inside a byte into a new byte. For example '01010010' -> '01001010'
public static byte ToReversedByte(this byte b)
Parameters
b
byteThe byte to reverse the bits of
Returns
- byte
A new byte containing the result