CKTIS / C#
System.Memory: praktična referenca
System.Memory: praktična referenca: Memory<T> opisuje zvezno območje pomnilnika, ki lahko preživi sklad in prečka mejo async.
Različica: .NET API; verified against .NET 10 reference surface
Sintaksa
System.Memory /* select a documented member or constructor */Memory opisuje zvezno območje pomnilnika, ki lahko preživi sklad in prečka mejo async.
Uporabite za podajanje delov polj ali pomnilnika v lasti upravljavca brez kopiranja.
Medpomnilnik ostane v lasti svojega lastnika; Memory vira ne sprosti.
Slice preveri obseg, dostop po sprostitvi s strani lastnika pa je napaka.
Celoten program dejansko uporabi System.Memory; natančno pričakovani stdout je 9.
Primeri
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;
Memory<int> memory = new[] { 1, 2, 3 };
memory.Span[1] = 9;
Console.WriteLine(memory.Span[1]);
Rezultat
9
Celoten program dejansko uporabi `System.Memory`; natančno pričakovani stdout je `9`.