System.Memory.Data 1.0.2

System.Memory.Data library for .NET

Binary Data

The BinaryData type provides a lightweight abstraction for a payload of bytes. It provides convenient helper methods to get out commonly used primitives, such as streams, strings, or bytes. The assumption when converting to and from string is that the encoding is UTF-8.

Data ownership

When using the byte[] or ReadOnlyMemory<byte> constructors or methods, BinaryData will wrap the passed in bytes. When using streams, strings, or rich model types that will be serialized as Json, the data is converted into bytes and will be maintained by BinaryData. Thus, if you are using bytes to create your instance of BinaryData, changes to the underlying data will be reflected in BinaryData as it does not copy the bytes.

Usage

The main value of this type is its ability to easily convert from string to bytes to stream. This can greatly simplify API surface areas by exposing this type as opposed to numerous overloads or properties.

To/From string:

var data = new BinaryData("some data");

// ToString will decode the bytes using UTF-8
Console.WriteLine(data.ToString()); // prints "some data"

To/From bytes:

byte[] bytes = Encoding.UTF8.GetBytes("some data");

// Create BinaryData using a constructor ...
BinaryData data = new BinaryData(bytes);

// Or using a static factory method.
data = BinaryData.FromBytes(bytes);

// There is an implicit cast defined for ReadOnlyMemory<byte>
ReadOnlyMemory<byte> rom = data;

// There is also an implicit cast defined for ReadOnlySpan<byte>
ReadOnlySpan<byte> ros = data;

// there is also a ToMemory method that gives access to the ReadOnlyMemory.
rom = data.ToMemory();

// and a ToArray method that converts into a byte array.
byte[] array = data.ToArray();

To/From stream:

var bytes = Encoding.UTF8.GetBytes("some data");
Stream stream = new MemoryStream(bytes);
var data = BinaryData.FromStream(stream);

// Calling ToStream will give back a stream that is backed by ReadOnlyMemory, so it is not writable.
stream = data.ToStream();
Console.WriteLine(stream.CanWrite); // prints false

BinaryData also can be used to integrate with ObjectSerializer. By default, the JsonObjectSerializer will be used, but any serializer deriving from ObjectSerializer can be used.

var model = new CustomModel
{
    A = "some text",
    B = 5,
    C = true
};

var data = BinaryData.FromObjectAsJson(model);
model = data.ToObjectFromJson<CustomModel>();

Showing the top 20 packages that depend on System.Memory.Data.

Packages Downloads
Azure.Core
This is the implementation of the Azure Client Pipeline
29
Azure.Core
This is the implementation of the Azure Client Pipeline
31
Azure.Core
This is the implementation of the Azure Client Pipeline
43
Azure.Core
This is the implementation of the Azure Client Pipeline
58
Azure.Core
This is the implementation of the Azure Client Pipeline
340
Azure.Core
This is the implementation of the Azure Client Pipeline
387
Azure.Messaging.EventGrid
This library can be used to publish events to Azure Event Grid and to consume events delivered by EventGrid. It also defines the event schemas for the events published to EventGrid by various Azure services.
27
Microsoft.Azure.WebJobs
This package contains the runtime assemblies for Microsoft.Azure.WebJobs.Host. It also adds rich diagnostics capabilities which makes it easier to monitor the WebJobs in the dashboard. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=320971
31
Microsoft.Azure.WebJobs
This package contains the runtime assemblies for Microsoft.Azure.WebJobs.Host. It also adds rich diagnostics capabilities which makes it easier to monitor the WebJobs in the dashboard. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=320971
33
Microsoft.Azure.WebJobs
This package contains the runtime host components of the WebJobs SDK. For more information, please visit https://go.microsoft.com/fwlink/?linkid=2279708.
33
Microsoft.Azure.WebJobs.Core
This library simplifies the task of adding background processing to your Microsoft Azure Web Sites. The SDK uses Microsoft Azure Storage, triggering a function in your program when items are added to Queues and Blobs. A dashboard provides rich monitoring and diagnostics for the programs that you write by using the SDK. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=320971
27
Microsoft.Azure.WebJobs.Core
This library simplifies the task of adding background processing to your Microsoft Azure Web Sites. The SDK uses Microsoft Azure Storage, triggering a function in your program when items are added to Queues and Blobs. A dashboard provides rich monitoring and diagnostics for the programs that you write by using the SDK. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=320971
43
System.ClientModel
Contains building blocks for clients that call cloud services.
29
System.ClientModel
Contains building blocks for clients that call cloud services.
34
System.ClientModel
Contains building blocks for clients that call cloud services.
36

https://github.com/Azure/azure-sdk-for-net/blob/System.Memory.Data_1.0.2/sdk/core/System.Memory.Data/CHANGELOG.md

.NET Framework 4.6.1

.NET Standard 2.0

Version Downloads Last updated
10.0.0-preview.6.25358.103 1 07/17/2025
10.0.0-preview.5.25277.114 6 06/08/2025
10.0.0-preview.4.25258.110 10 05/19/2025
10.0.0-preview.3.25171.5 11 04/24/2025
10.0.0-preview.2.25163.2 13 03/26/2025
10.0.0-preview.1.25080.5 13 03/03/2025
9.0.7 1 07/19/2025
9.0.6 6 06/15/2025
9.0.5 6 05/18/2025
9.0.4 9 04/24/2025
9.0.3 12 03/26/2025
9.0.2 13 03/08/2025
9.0.1 18 01/31/2025
9.0.0 21 11/14/2024
9.0.0-rc.2.24473.5 23 10/24/2024
9.0.0-rc.1.24431.7 24 09/13/2024
9.0.0-preview.7.24405.7 22 08/14/2024
9.0.0-preview.6.24327.7 22 07/10/2024
9.0.0-preview.5.24306.7 27 06/24/2024
9.0.0-preview.4.24266.19 21 05/22/2024
9.0.0-preview.3.24172.9 29 04/12/2024
9.0.0-preview.2.24128.5 26 03/12/2024
9.0.0-preview.1.24080.9 27 03/12/2024
8.0.1 23 10/26/2024
8.0.0 32 02/08/2024
8.0.0-rc.2.23479.6 28 02/05/2024
8.0.0-rc.1.23419.4 27 02/05/2024
8.0.0-preview.7.23375.6 26 02/08/2024
8.0.0-preview.6.23329.7 26 02/08/2024
8.0.0-preview.5.23280.8 23 02/08/2024
8.0.0-preview.4.23259.5 24 02/08/2024
8.0.0-preview.3.23174.8 24 02/08/2024
8.0.0-preview.2.23128.3 26 02/08/2024
8.0.0-preview.1.23110.8 22 02/08/2024
7.0.0 38 02/08/2024
7.0.0-rc.2.22472.3 28 02/05/2024
7.0.0-rc.1.22426.10 33 02/08/2024
7.0.0-preview.7.22375.6 28 02/08/2024
7.0.0-preview.6.22324.4 30 02/08/2024
7.0.0-preview.5.22301.12 29 02/08/2024
7.0.0-preview.4.22229.4 27 02/08/2024
7.0.0-preview.3.22175.4 23 02/08/2024
7.0.0-preview.2.22152.2 24 02/08/2024
7.0.0-preview.1.22076.8 28 02/08/2024
6.0.2-mauipre.1.22102.15 25 02/08/2024
6.0.2-mauipre.1.22054.8 26 02/08/2024
6.0.1 18 11/14/2024
6.0.0 40 03/01/2022
6.0.0-rc.2.21480.5 30 02/05/2024
6.0.0-rc.1.21451.13 27 02/08/2024
6.0.0-preview.7.21377.19 23 02/08/2024
6.0.0-preview.6.21352.12 24 02/08/2024
6.0.0-preview.5.21301.5 29 02/08/2024
6.0.0-preview.4.21253.7 26 02/08/2024
6.0.0-preview.3.21201.4 26 02/08/2024
6.0.0-preview.2.21154.6 30 02/08/2024
6.0.0-preview.1.21102.12 26 02/08/2024
1.0.2 295 06/15/2021
1.0.1 31 02/08/2024
1.0.0 27 02/08/2024
1.0.0-beta.2 34 02/08/2024
1.0.0-beta.1 41 02/08/2024