CKTIS / C#
System.ReadOnlyMemory: riferimento pratico
System.ReadOnlyMemory: riferimento pratico: ReadOnlyMemory<T> offre una vista durevole in sola lettura di un buffer utilizzabile oltre i confini async.
Versione: .NET API; verified against .NET 10 reference surface
Sintassi
System.ReadOnlyMemory /* select a documented member or constructor */ReadOnlyMemory offre una vista durevole in sola lettura di un buffer utilizzabile oltre i confini async.
Usalo come parametro quando il destinatario non deve modificare gli elementi.
ReadOnly riguarda la vista; il proprietario può ancora modificare il buffer sottostante.
Slice convalida l’intervallo e la memoria non è valida dopo il rilascio da parte del proprietario.
Il programma completo usa realmente System.ReadOnlyMemory; lo stdout esatto atteso è bc.
Esempi
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());
Risultato
bc
Il programma completo usa realmente `System.ReadOnlyMemory`; lo stdout esatto atteso è `bc`.