Tedd.SpanUtils 1.0.2

Adds extension methods to read/write to Span<byte>

There is a newer version of this package available.
See the version list below for details.
Install-Package Tedd.SpanUtils -Version 1.0.2
dotnet add package Tedd.SpanUtils --version 1.0.2
<PackageReference Include="Tedd.SpanUtils" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Tedd.SpanUtils --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Tedd.SpanUtils, 1.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Tedd.SpanUtils as a Cake Addin
#addin nuget:?package=Tedd.SpanUtils&version=1.0.2

// Install Tedd.SpanUtils as a Cake Tool
#tool nuget:?package=Tedd.SpanUtils&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Tedd.SpanUtils

Utilities for reading/writing to span.

Span<byte> extension methods to read or write SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64. There is also an UInt24 type which can be cast to/from UInt32 and used for reading/writing 3-byte numbers.

Example

var mem = new byte[1000];
var span = new Span<byte>(mem);

Int32 a = 1234;
span.Write(a);
var b = span.ReadInt32(i);
// a == b


// Move* methods moves Span-pointer as they read or write.
Int16 a1 = 10;
Int32 a2 = 20;
Int64 a3 = 30;
span.MoveWrite(a1);
span.MoveWrite(a2);
span.MoveWrite(a3);

// To start reading from start we need a new reference for reader pointing to start of memory area.
var span2 = new Span<byte(mem);

var b1 = span2.MoveReadInt16();
var b2 = span2.MoveReadInt32();
var b3 = span2.MoveReadInt64();

// a1 == b1
// a2 == b2
// a3 == b3

Tedd.SpanUtils

Utilities for reading/writing to span.

Span<byte> extension methods to read or write SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64. There is also an UInt24 type which can be cast to/from UInt32 and used for reading/writing 3-byte numbers.

Example

var mem = new byte[1000];
var span = new Span<byte>(mem);

Int32 a = 1234;
span.Write(a);
var b = span.ReadInt32(i);
// a == b


// Move* methods moves Span-pointer as they read or write.
Int16 a1 = 10;
Int32 a2 = 20;
Int64 a3 = 30;
span.MoveWrite(a1);
span.MoveWrite(a2);
span.MoveWrite(a3);

// To start reading from start we need a new reference for reader pointing to start of memory area.
var span2 = new Span<byte(mem);

var b1 = span2.MoveReadInt16();
var b2 = span2.MoveReadInt32();
var b3 = span2.MoveReadInt64();

// a1 == b1
// a2 == b2
// a3 == b3

  • .NETCoreApp 2.1

    • No dependencies.
  • .NETCoreApp 3.0

    • No dependencies.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.6.1

  • .NETStandard 2.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Tedd.SpanUtils:

Package Downloads
Tedd.NetworkMessageProtocol
Simple and fast message based TCP network communication library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.0-beta.7 92 1/8/2021
1.1.0-beta.6 140 5/9/2020
1.1.0-beta.5 129 5/6/2020
1.1.0-beta.4 157 5/4/2020
1.1.0-beta.3 207 5/3/2020
1.1.0-beta.2 147 5/2/2020
1.1.0-beta.1 148 5/2/2020
1.0.8 430 1/4/2020
1.0.7 224 1/3/2020
1.0.6 209 1/3/2020
1.0.5 209 1/3/2020
1.0.4 227 12/26/2019
1.0.2 191 12/23/2019
1.0.1 191 12/23/2019
1.0.0 205 12/19/2019
Show less