System.Memory.Data 9.0.19

About

System.Memory.Data introduces the BinaryData type, a lightweight abstraction for a byte payload. It makes it easy to convert between string, bytes, and stream.

This abstraction can simplify the API surface by exposing a single type instead of numerous overloads or properties. The BinaryData type handles data ownership efficiently, wrapping passed-in bytes when using byte[] or ReadOnlyMemory<byte> constructors or methods, and managing data as bytes when dealing with streams, strings, or rich model types serialized as JSON.

Key Features

  • Lightweight abstraction for byte payload via BinaryData type.
  • Convenient helper methods for common conversions among string, bytes, and stream.
  • Efficient data ownership handling.

How to Use

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>();

Main Types

The main types provided by this library are:

  • System.BinaryData

Additional Documentation

Feedback & Contributing

System.Memory.Data is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

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

Packages Downloads
System.ClientModel
Contains building blocks for clients that call cloud services.
62
Azure.Core
This is the implementation of the Azure Client Pipeline
55
System.ClientModel
Contains building blocks for clients that call cloud services.
55
Azure.Core
This is the implementation of the Azure Client Pipeline
54
Azure.Core
This is the implementation of the Azure Client Pipeline
53
Azure.Storage.Queues
This client library enables working with the Microsoft Azure Storage Queue service for storing messages that may be accessed by a client. For this release see notes - https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Queues/README.md and https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Queues/CHANGELOG.md in addition to the breaking changes https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Queues/BreakingChanges.txt Microsoft Azure Storage quickstarts and tutorials - https://docs.microsoft.com/en-us/azure/storage/ Microsoft Azure Storage REST API Reference - https://docs.microsoft.com/en-us/rest/api/storageservices/ REST API Reference for Queue Service - https://docs.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api
52
Azure.Messaging.ServiceBus
Azure Service Bus is a fully managed enterprise integration message broker. Service Bus can decouple applications and services. Service Bus offers a reliable and secure platform for asynchronous transfer of data and state. This client library allows for both sending and receiving messages using Azure Service Bus. For more information about Service Bus, see https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview
50
System.ClientModel
Contains building blocks for clients that call cloud services.
50
Azure.Core
This is the implementation of the Azure Client Pipeline
50
Azure.Storage.Queues
This client library enables working with the Microsoft Azure Storage Queue service for storing messages that may be accessed by a client. For this release see notes - https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Queues/README.md and https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Queues/CHANGELOG.md in addition to the breaking changes https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Queues/BreakingChanges.txt Microsoft Azure Storage quickstarts and tutorials - https://docs.microsoft.com/en-us/azure/storage/ Microsoft Azure Storage REST API Reference - https://docs.microsoft.com/en-us/rest/api/storageservices/ REST API Reference for Queue Service - https://docs.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api
50
Azure.Messaging.ServiceBus
Azure Service Bus is a fully managed enterprise integration message broker. Service Bus can decouple applications and services. Service Bus offers a reliable and secure platform for asynchronous transfer of data and state. This client library allows for both sending and receiving messages using Azure Service Bus. For more information about Service Bus, see https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview
49
Azure.Storage.Queues
This client library enables working with the Microsoft Azure Storage Queue service for storing messages that may be accessed by a client. For this release see notes - https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Queues/README.md and https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Queues/CHANGELOG.md in addition to the breaking changes https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Queues/BreakingChanges.txt Microsoft Azure Storage quickstarts and tutorials - https://docs.microsoft.com/en-us/azure/storage/ Microsoft Azure Storage REST API Reference - https://docs.microsoft.com/en-us/rest/api/storageservices/ REST API Reference for Queue Service - https://docs.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api
49
Azure.Core
This is the implementation of the Azure Client Pipeline
49
System.ClientModel
Contains building blocks for clients that call cloud services.
49
Azure.Messaging.EventHubs
Azure Event Hubs is a highly scalable publish-subscribe service that can ingest millions of events per second and stream them to multiple consumers. This client library allows for both publishing and consuming events using Azure Event Hubs. For more information about Event Hubs, see https://azure.microsoft.com/en-us/services/event-hubs/
48
Azure.Messaging.ServiceBus
Azure Service Bus is a fully managed enterprise integration message broker. Service Bus can decouple applications and services. Service Bus offers a reliable and secure platform for asynchronous transfer of data and state. This client library allows for both sending and receiving messages using Azure Service Bus. For more information about Service Bus, see https://learn.microsoft.com/azure/service-bus-messaging/service-bus-messaging-overview
48

.NET Framework 4.6.2

.NET 8.0

.NET 9.0

  • No dependencies.

.NET Standard 2.0

Version Downloads Last updated
11.0.0-rc.1.26425.128 14 09/09/2026
11.0.0-preview.7.26381.103 12 08/13/2026
11.0.0-preview.6.26359.118 14 07/19/2026
11.0.0-preview.5.26302.115 23 06/11/2026
11.0.0-preview.4.26230.115 27 05/15/2026
11.0.0-preview.3.26207.106 39 04/14/2026
11.0.0-preview.2.26159.112 41 03/13/2026
11.0.0-preview.1.26104.118 45 02/15/2026
10.0.12 12 09/11/2026
10.0.11 17 08/13/2026
10.0.10 18 07/19/2026
10.0.9 21 06/11/2026
10.0.8 27 05/15/2026
10.0.7 39 04/23/2026
10.0.6 39 04/15/2026
10.0.5 41 03/14/2026
10.0.4 33 03/14/2026
10.0.3 46 02/15/2026
10.0.2 55 01/16/2026
10.0.1 47 12/10/2025
10.0.0 50 12/12/2025
10.0.0-rc.2.25502.107 47 12/12/2025
10.0.0-rc.1.25451.107 50 12/12/2025
10.0.0-preview.7.25380.108 46 12/10/2025
10.0.0-preview.6.25358.103 45 12/10/2025
10.0.0-preview.5.25277.114 44 12/11/2025
10.0.0-preview.4.25258.110 45 12/10/2025
10.0.0-preview.3.25171.5 44 12/10/2025
10.0.0-preview.2.25163.2 45 12/14/2025
10.0.0-preview.1.25080.5 40 12/20/2025
9.0.20 9 09/09/2026
9.0.19 13 08/13/2026
9.0.18 16 07/19/2026
9.0.17 20 06/11/2026
9.0.16 24 05/15/2026
9.0.15 39 04/15/2026
9.0.14 39 03/14/2026
9.0.13 43 02/15/2026
9.0.12 50 01/15/2026
9.0.11 42 12/12/2025
9.0.10 48 12/12/2025
9.0.9 47 12/12/2025
9.0.8 46 12/11/2025
9.0.7 44 12/12/2025
9.0.6 47 12/11/2025
9.0.5 47 12/11/2025
9.0.4 38 12/27/2025
9.0.3 45 12/14/2025
9.0.2 44 12/11/2025
9.0.1 42 12/11/2025
9.0.0 43 12/12/2025
9.0.0-rc.2.24473.5 36 01/03/2026
9.0.0-rc.1.24431.7 36 12/10/2025
9.0.0-preview.7.24405.7 36 12/12/2025
9.0.0-preview.6.24327.7 33 12/09/2025
9.0.0-preview.5.24306.7 35 12/13/2025
9.0.0-preview.4.24266.19 34 12/14/2025
9.0.0-preview.3.24172.9 37 12/10/2025
9.0.0-preview.2.24128.5 36 12/13/2025
9.0.0-preview.1.24080.9 31 12/20/2025
8.0.1 46 12/10/2025
8.0.0 36 12/13/2025
8.0.0-rc.2.23479.6 38 12/12/2025
8.0.0-rc.1.23419.4 35 12/10/2025
8.0.0-preview.7.23375.6 32 12/12/2025
8.0.0-preview.6.23329.7 37 12/12/2025
8.0.0-preview.5.23280.8 30 12/11/2025
8.0.0-preview.4.23259.5 33 12/12/2025
8.0.0-preview.3.23174.8 39 12/12/2025
8.0.0-preview.2.23128.3 45 12/12/2025
8.0.0-preview.1.23110.8 40 12/11/2025
7.0.0 31 12/12/2025
7.0.0-rc.2.22472.3 30 12/12/2025
7.0.0-rc.1.22426.10 39 12/11/2025
7.0.0-preview.7.22375.6 35 12/12/2025
7.0.0-preview.6.22324.4 40 12/13/2025
7.0.0-preview.5.22301.12 36 12/13/2025
7.0.0-preview.4.22229.4 40 12/13/2025
7.0.0-preview.3.22175.4 34 12/13/2025
7.0.0-preview.2.22152.2 36 12/13/2025
7.0.0-preview.1.22076.8 31 12/13/2025
6.0.2-mauipre.1.22102.15 37 12/13/2025
6.0.2-mauipre.1.22054.8 37 12/13/2025
6.0.1 46 12/10/2025
6.0.0 37 12/13/2025
6.0.0-rc.2.21480.5 36 12/13/2025
6.0.0-rc.1.21451.13 33 12/13/2025
6.0.0-preview.7.21377.19 36 12/13/2025
6.0.0-preview.6.21352.12 38 12/12/2025
6.0.0-preview.5.21301.5 33 12/13/2025
6.0.0-preview.4.21253.7 42 12/12/2025
6.0.0-preview.3.21201.4 34 12/13/2025
6.0.0-preview.2.21154.6 40 12/13/2025
6.0.0-preview.1.21102.12 39 12/12/2025
1.0.2 41 12/12/2025
1.0.1 36 12/11/2025
1.0.0 29 12/12/2025
1.0.0-beta.2 35 12/12/2025
1.0.0-beta.1 39 12/12/2025