CKTIS / C#
System.Memory: praktická referencia
System.Memory: praktická referencia: Memory<T> opisuje súvislú oblasť pamäte, ktorá môže prežiť zásobník a prejsť cez hranicu async.
Verzia: .NET API; verified against .NET 10 reference surface
Syntax
System.Memory /* select a documented member or constructor */Memory opisuje súvislú oblasť pamäte, ktorá môže prežiť zásobník a prejsť cez hranicu async.
Použite na odovzdávanie častí polí alebo pamäte spravovanej vlastníkom bez kopírovania.
Buffer zostáva vo vlastníctve svojho vlastníka; Memory prostriedok neuvoľňuje.
Slice kontroluje rozsah a prístup po uvoľnení vlastníkom je chybou.
Úplný program skutočne používa System.Memory; presne očakávaný stdout je 9.
Prí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;
Memory<int> memory = new[] { 1, 2, 3 };
memory.Span[1] = 9;
Console.WriteLine(memory.Span[1]);
Výsledok
9
Úplný program skutočne používa `System.Memory`; presne očakávaný stdout je `9`.