Soenneker.Extensions.MemoryStream 4.0.619

Prefix Reserved
dotnet add package Soenneker.Extensions.MemoryStream --version 4.0.619
                    
NuGet\Install-Package Soenneker.Extensions.MemoryStream -Version 4.0.619
                    
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.619" />
                    
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.619" />
                    
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.619
                    
#r "nuget: Soenneker.Extensions.MemoryStream, 4.0.619"
                    
#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.619
                    
#: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.619
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.MemoryStream&version=4.0.619
                    
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.619 38 9/12/2026
4.0.618 572 8/30/2026
4.0.617 108 8/29/2026
4.0.615 98 8/29/2026
4.0.614 95 8/29/2026
4.0.613 115 7/27/2026
4.0.612 113 7/16/2026
4.0.611 133 6/18/2026
4.0.610 139 6/5/2026
4.0.609 126 6/5/2026
4.0.608 138 4/22/2026
4.0.607 144 3/12/2026
4.0.606 136 3/12/2026
4.0.605 130 3/12/2026
4.0.604 144 3/12/2026
4.0.603 137 3/10/2026
4.0.602 137 3/9/2026
4.0.601 127 3/9/2026
4.0.600 134 3/9/2026
4.0.599 135 3/4/2026
Loading failed

Use NuGet trusted publishing in publishing workflows