Soenneker.Extensions.MemoryStream 4.0.618

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Extensions.MemoryStream --version 4.0.618
                    
NuGet\Install-Package Soenneker.Extensions.MemoryStream -Version 4.0.618
                    
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="Soenneker.Extensions.MemoryStream" Version="4.0.618" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.MemoryStream" Version="4.0.618" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.MemoryStream" />
                    
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 Soenneker.Extensions.MemoryStream --version 4.0.618
                    
#r "nuget: Soenneker.Extensions.MemoryStream, 4.0.618"
                    
#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 Soenneker.Extensions.MemoryStream@4.0.618
                    
#: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=Soenneker.Extensions.MemoryStream&version=4.0.618
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.MemoryStream&version=4.0.618
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Extensions.MemoryStream

Extension methods for working with MemoryStream instances, including efficient buffer access, conversion, positioning, and other common stream operations.

Installation

dotnet add package Soenneker.Extensions.MemoryStream

Expose the valid buffer without copying

using Soenneker.Extensions.MemoryStream;

using var stream = new MemoryStream();
stream.Write([1, 2, 3]);

ReadOnlyMemory<byte> bytes = stream.ToReadOnlyMemoryBytes(); // [1, 2, 3]

ToReadOnlyMemoryBytes() returns a zero-copy ReadOnlyMemory<byte> view over the stream's valid underlying buffer segment. The stream's current Position does not affect the returned range.

For a stream created over an array segment, the returned memory begins at that segment's offset rather than at index zero of the underlying array:

byte[] buffer = [99, 1, 2, 3, 88];
using var stream = new MemoryStream(buffer, 1, 3, writable: false, publiclyVisible: true);

ReadOnlyMemory<byte> bytes = stream.ToReadOnlyMemoryBytes(); // [1, 2, 3]

Because the memory aliases the stream buffer, later writes through the stream or another owner of the array can be visible through the returned memory. ReadOnlyMemory<byte> prevents mutation through this particular view; it does not make the underlying bytes immutable or create a snapshot. Call ToArray() on the returned memory when an independent copy is required.

Buffer visibility must be permitted. A MemoryStream created over a non-publicly-visible external buffer throws UnauthorizedAccessException. A null or disposed/inaccessible stream follows the underlying MemoryStream buffer APIs' exception behavior.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.620 43 9/15/2026
4.0.619 60 9/12/2026
4.0.618 575 8/30/2026
4.0.617 112 8/29/2026
4.0.615 104 8/29/2026
4.0.614 99 8/29/2026
4.0.613 118 7/27/2026
4.0.612 115 7/16/2026
4.0.611 135 6/18/2026
4.0.610 141 6/5/2026
4.0.609 128 6/5/2026
4.0.608 140 4/22/2026
4.0.607 146 3/12/2026
4.0.606 140 3/12/2026
4.0.605 132 3/12/2026
4.0.604 146 3/12/2026
4.0.603 139 3/10/2026
4.0.602 139 3/9/2026
4.0.601 129 3/9/2026
4.0.600 136 3/9/2026
Loading failed

Respect MemoryStream segment boundaries