CKTIS / C#
System.ReadOnlyMemory: praktická reference
System.ReadOnlyMemory: praktická reference: ReadOnlyMemory<T> poskytuje trvalý pohled jen pro čtení na buffer, použitelný přes hranice async.
Verze: .NET API; verified against .NET 10 reference surface
Syntaxe
System.ReadOnlyMemory /* select a documented member or constructor */ReadOnlyMemory poskytuje trvalý pohled jen pro čtení na buffer, použitelný přes hranice async.
Použijte jako parametr, když příjemce nesmí měnit prvky.
ReadOnly platí pro pohled; vlastník může podkladový buffer stále změnit.
Slice kontroluje rozsah a paměť je po uvolnění vlastníkem neplatná.
Úplný program skutečně používá System.ReadOnlyMemory; přesně očekávaný stdout je bc.
Příklady
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());
Výsledek
bc
Úplný program skutečně používá `System.ReadOnlyMemory`; přesně očekávaný stdout je `bc`.