CKTIS / C#
System.IO.StringReader: praktična referenca
System.IO.StringReader: praktična referenca: StringReader ponuja obstoječi niz prek pogodbe TextReader.
Različica: .NET API; verified on .NET 10.0.14
Sintaksa
System.IO.StringReader /* select a documented member or constructor */StringReader ponuja obstoječi niz prek pogodbe TextReader.
Uporabite ga za razčlenjevalnike, ki pričakujejo TextReader brez začasne datoteke.
ReadLine odstrani ločilo, Dispose konča uporabo in celotno izvorno besedilo je že v pomnilniku.
ReadLine po koncu vrne null. Končno ločilo zaključi prejšnjo vrstico in ne ustvari dodatne prazne vrstice; začetno ali zaporedna ločila lahko ustvarijo prazno vrstico.
Celoten program dejansko uporabi System.IO.StringReader; natančno pričakovani stdout je first.
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;
using var reader = new StringReader("first\nsecond");
Console.WriteLine(reader.ReadLine());
Rezultat
first
Celoten program dejansko uporabi `System.IO.StringReader`; natančno pričakovani stdout je `first`.