CKTIS / C#
System.IO.MemoryStream: praktična referenca
System.IO.MemoryStream: praktična referenca: MemoryStream je tok bajtova u memoriji s Position, Length i Capacity.
Verzija: .NET API; verified on .NET 10.0.14
Sintaksa
System.IO.MemoryStream /* select a documented member or constructor */MemoryStream je tok bajtova u memoriji s Position, Length i Capacity.
Koristite ga za male ili srednje međuspremnike kojima treba Stream API bez datotečnog I/O-a.
ToArray kopira, GetBuffer može izložiti neiskorišteni kapacitet, a Dispose ne briše osjetljive podatke.
Seek iza Length mijenja samo Position; ne proširuje tok niti stvara bajtove. Prazninu nulama popunjava tek naknadno proširujuće pisanje ili SetLength; tok nad postojećim poljem možda nije proširiv.
Cijeli program doista koristi System.IO.MemoryStream; točno očekivani stdout jest 65.
Primjeri
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;
using var stream = new MemoryStream();
stream.WriteByte(65);
Console.WriteLine(stream.ToArray()[0]);
Rezultat
65
Cijeli program doista koristi `System.IO.MemoryStream`; točno očekivani stdout jest `65`.