C# library for converting from and to bytes. Without the boring repetition.
In this repository
- Bny.RawBytes: the library
- Bny.RawBytes.Tester: unit tests
How to use
Code
using Bny.RawBytes;
var arr = new byte[] { 0, 2, 0, 0, 0, 2, 0, 0 };
Console.WriteLine(
Bytes.
To<BinaryTest>(arr, Endianness.Big));
[BinaryObject]
class BinaryTest
{
[BinaryMember(endianness: Endianness.Little)]
public int Width { get; init; }
[BinaryMember]
public int Height { get; init; }
public int Size => Width * Height;
public override string ToString() => $"[{Size}({Width} * {Height})]";
}
Contains functions for converting from and to byte array
Definition: Bytes.cs:10
static object To(ReadOnlySpan< byte > data, Type type, BytesParam? par=null)
Converts byte array to the given type
Output
Links