CKTIS / C#
System.ReadOnlyMemory: practical reference
System.ReadOnlyMemory: practical reference: ReadOnlyMemory<T> provides a durable read-only buffer view that can be used across async boundaries.
Version: .NET API; verified against .NET 10 reference surface
Syntax
System.ReadOnlyMemory /* select a documented member or constructor */ReadOnlyMemory provides a durable read-only buffer view that can be used across async boundaries.
Use it as a parameter when the receiver must not modify elements.
ReadOnly applies to the view; the owner can still change the underlying buffer.
Slice validates the range, and the memory is invalid after its owner releases it.
The complete program actually uses System.ReadOnlyMemory; its exact expected stdout is bc.
Examples
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
ReadOnlyMemory<char> memory = "abcd".AsMemory(1, 2);
Console.WriteLine(memory.ToString());
Result
bc
The complete program actually uses `System.ReadOnlyMemory`; its exact expected stdout is `bc`.