Microsoft.Bcl.Memory 9.0.20

About

Provides Index and Range types to simplify slicing operations on collections for .NET Framework and .NET Standard 2.0. Provides Base64Url for encoding data in a URL-safe manner on .NET Framework and .NET Standard.

This library is not necessary nor recommended when targeting versions of .NET that include the relevant support.

Key Features

  • Enables the use of Index and Range types on older .NET platforms.
  • Provides Base64Url encoding, decoding, and validation for URL-safe data processing on older .NET platforms.

How to Use

The Index and Range types simplify working with slices of arrays, strings, or other collections.

string[] words = ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"];

// Use Index to reference the last element
Console.WriteLine(words[^1]);
// Output: "dog"

// Use Range to reference a slice
string[] phrase = words[1..4];
Console.WriteLine(string.Join(" ", phrase));
// Output: "quick brown fox"

Base64Url encoding is a URL-safe version of Base64, commonly used in web applications, such as JWT tokens.

using System.Buffers.Text;
using System.Text;

// Original data
byte[] data = Encoding.UTF8.GetBytes("Hello World!");

Span<byte> encoded = new byte[Base64Url.GetEncodedLength(data.Length)];
Base64Url.EncodeToUtf8(data, encoded, out int _, out int bytesWritten);

string encodedString = Base64Url.EncodeToString(data);  
Console.WriteLine($"Encoded: {encodedString}");
// Encoded: SGVsbG8gV29ybGQh

Span<byte> decoded = new byte[data.Length];
Base64Url.DecodeFromUtf8(encoded[..bytesWritten], decoded, out _, out bytesWritten);

string decodedString = Encoding.UTF8.GetString(decoded[..bytesWritten]);
Console.WriteLine($"Decoded: {decodedString}");
// Decoded: Hello World!

Main Types

The main types provided by this library are:

  • System.Index
  • System.Range
  • System.Buffers.Text.Base64Url

Additional Documentation

API documentation

Feedback & Contributing

Microsoft.Bcl.Memory 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 Microsoft.Bcl.Memory.

Packages Downloads
Duende.IdentityModel
OpenID Connect & OAuth 2.0 client library
83
Duende.IdentityModel
OpenID Connect & OAuth 2.0 client library
125
Microsoft.IdentityModel.Tokens
Includes types that provide support for SecurityTokens, Cryptographic operations: Signing, Verifying Signatures, Encryption.
127
Microsoft.IdentityModel.Tokens
Includes types that provide support for SecurityTokens, Cryptographic operations: Signing, Verifying Signatures, Encryption.
130
Microsoft.IdentityModel.Tokens
Includes types that provide support for SecurityTokens, Cryptographic operations: Signing, Verifying Signatures, Encryption.
138
Microsoft.IdentityModel.Tokens
Includes types that provide support for SecurityTokens, Cryptographic operations: Signing, Verifying Signatures, Encryption.
151
Microsoft.IdentityModel.Tokens
Includes types that provide support for SecurityTokens, Cryptographic operations: Signing, Verifying Signatures, Encryption.
164
Microsoft.IdentityModel.Tokens
Includes types that provide support for SecurityTokens, Cryptographic operations: Signing, Verifying Signatures, Encryption.
171
Microsoft.IdentityModel.Tokens
Includes types that provide support for SecurityTokens, Cryptographic operations: Signing, Verifying Signatures, Encryption.
173
Microsoft.IdentityModel.Tokens
Includes types that provide support for SecurityTokens, Cryptographic operations: Signing, Verifying Signatures, Encryption.
509
System.Linq.AsyncEnumerable
System.Linq.AsyncEnumerable
78
System.Linq.AsyncEnumerable
System.Linq.AsyncEnumerable
80
System.Linq.AsyncEnumerable
System.Linq.AsyncEnumerable
85
System.Linq.AsyncEnumerable
System.Linq.AsyncEnumerable
89
System.Linq.AsyncEnumerable
System.Linq.AsyncEnumerable
91
System.Linq.AsyncEnumerable
System.Linq.AsyncEnumerable
97
System.Linq.AsyncEnumerable
System.Linq.AsyncEnumerable
98
System.Linq.AsyncEnumerable
System.Linq.AsyncEnumerable
103

https://go.microsoft.com/fwlink/?LinkID=799421

.NET Framework 4.6.2

.NET 8.0

  • No dependencies.

.NET 9.0

  • No dependencies.

.NET Standard 2.0

.NET Standard 2.1

Version Downloads Last updated
11.0.0-rc.1.26425.128 1 09/11/2026
11.0.0-preview.7.26381.103 14 08/12/2026
11.0.0-preview.6.26359.118 19 07/16/2026
11.0.0-preview.5.26302.115 28 06/12/2026
11.0.0-preview.4.26230.115 27 05/14/2026
11.0.0-preview.3.26207.106 44 04/14/2026
11.0.0-preview.2.26159.112 45 03/12/2026
11.0.0-preview.1.26104.118 44 02/12/2026
10.0.12 2 09/10/2026
10.0.11 18 08/12/2026
10.0.10 19 07/18/2026
10.0.9 24 06/12/2026
10.0.8 26 05/14/2026
10.0.7 34 04/21/2026
10.0.6 43 04/14/2026
10.0.5 39 03/16/2026
10.0.4 42 03/12/2026
10.0.3 50 02/12/2026
10.0.2 56 01/13/2026
10.0.1 63 12/09/2025
10.0.0 79 11/12/2025
10.0.0-rc.2.25502.107 96 10/15/2025
10.0.0-rc.1.25451.107 103 09/12/2025
10.0.0-preview.7.25380.108 86 08/16/2025
10.0.0-preview.6.25358.103 107 07/16/2025
10.0.0-preview.5.25277.114 111 06/06/2025
10.0.0-preview.4.25258.110 126 05/17/2025
10.0.0-preview.3.25171.5 125 04/11/2025
10.0.0-preview.2.25163.2 110 04/05/2025
10.0.0-preview.1.25080.5 112 04/07/2025
9.0.20 2 09/10/2026
9.0.19 19 08/12/2026
9.0.18 17 07/18/2026
9.0.17 23 06/12/2026
9.0.16 27 05/14/2026
9.0.15 43 04/14/2026
9.0.14 46 03/12/2026
9.0.13 53 02/12/2026
9.0.12 54 01/13/2026
9.0.11 76 11/12/2025
9.0.10 90 10/15/2025
9.0.9 95 09/12/2025
9.0.8 98 08/07/2025
9.0.7 104 07/11/2025
9.0.6 135 06/15/2025
9.0.5 115 05/18/2025
9.0.4 136 04/11/2025
9.0.3 122 04/07/2025
9.0.2 122 04/06/2025
9.0.1 152 04/07/2025
9.0.0 120 04/07/2025
9.0.0-rc.2.24473.5 112 04/07/2025
9.0.0-rc.1.24431.7 96 04/06/2025
9.0.0-preview.7.24405.7 109 04/07/2025