BinaryBuffers 4.1.0

dotnet add package BinaryBuffers --version 4.1.0
                    
NuGet\Install-Package BinaryBuffers -Version 4.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BinaryBuffers" Version="4.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BinaryBuffers" Version="4.1.0" />
                    
Directory.Packages.props
<PackageReference Include="BinaryBuffers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BinaryBuffers --version 4.1.0
                    
#r "nuget: BinaryBuffers, 4.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BinaryBuffers@4.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BinaryBuffers&version=4.1.0
                    
Install as a Cake Addin
#tool nuget:?package=BinaryBuffers&version=4.1.0
                    
Install as a Cake Tool

BinaryBuffers

logo

NuGet

BinaryBuffers offers a highly performant implementation of BinaryReader and BinaryWriter, working directly on a byte array, thus eliminating the need for an intermediate Stream object.

How to use

BinaryBufferReader and BinaryBufferWriter are the respective names of the reader and writer. Both classes operate on a byte[] as its underlying data buffer.

// Provide a buffer to the reader/writer
var buffer = new byte[100];

// Write to the buffer
var writer = new BinaryBufferWriter(buffer);

writer.Write(2026);
writer.Write(8.11);

// Read from the buffer
var reader = new BinaryBufferReader(buffer);

var year = reader.ReadInt32();
var time = reader.ReadDouble();

Benchmarks

Benchmarks show an average of 69% improvement in reading and 79% in writing.

Performance tests were executed using .NET 10 running on a machine with a 16-core CPU.

BinaryBufferReader

Method Mean Error StdDev Ratio
BinaryReader_ReadInt 16.960 ms 0.0296 ms 0.0277 ms baseline
BufferReader_ReadInt 5.176 ms 0.0139 ms 0.0124 ms -69%
BinaryReader_ReadDecimal 14.323 ms 0.253 ms 0.211 ms baseline
BufferReader_ReadDecimal 4.383 ms 0.0179 ms 0.104 ms -69%
BinaryReader_ReadFloat 11.689 ms 0.0154 ms 0.0167 ms baseline
BufferReader_ReadFloat 3.724 ms 0.0150 ms 0.0144 ms -68%

BinaryBufferWriter

Method Mean Error StdDev Ratio
BinaryWriter_WriteInt 39.768 ms 0.0756 ms 0.0670 ms baseline
BufferWriter_WriteInt 8.361 ms 0.0120 ms 0.0107 ms -79%
BinaryWriter_WriteDecimal 27.283 ms 0.0133 ms 0.0118 ms baseline
BufferWriter_WriteDecimal 5.725 ms 0.0078 ms 0.0328 ms -79%
BinaryWriter_WriteFloat 20.537 ms 0.0533 ms 0.0499 ms baseline
BufferWriter_WriteFloat 4.488 ms 0.0161 ms 0.0151 ms -78%
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BinaryBuffers:

Package Downloads
LiteCDF

A high performance compound document format (CDF) reader.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.1.0 35 12/11/2025
4.0.0 246 11/16/2025
3.0.1 257 6/13/2024
2.0.2 1,215 6/19/2022