Znalostná bázaCentrum skúšok
SKSlovenčina
Vybrať jazyk13

CKTIS / C#

System.IO.StringReader: praktická referencia

System.IO.StringReader: praktická referencia: StringReader sprístupňuje existujúci reťazec cez kontrakt TextReader.

Verzia: .NET API; verified on .NET 10.0.14

Syntax

System.IO.StringReader /* select a documented member or constructor */

StringReader sprístupňuje existujúci reťazec cez kontrakt TextReader.

Použite ho pre parsery očakávajúce TextReader bez vytvárania dočasného súboru.

ReadLine odstráni oddeľovač, Dispose ukončí použitie a celý zdrojový text už je v pamäti.

ReadLine po konci vráti null. Koncový oddeľovač ukončí predchádzajúci riadok a nevytvorí ďalší prázdny riadok; počiatočný alebo po sebe idúce oddeľovače môžu vytvoriť prázdny riadok.

Úplný program skutočne používa System.IO.StringReader; presne očakávaný stdout je first.

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;

using var reader = new StringReader("first\nsecond");
Console.WriteLine(reader.ReadLine());

Výsledok

first

Úplný program skutočne používa `System.IO.StringReader`; presne očakávaný stdout je `first`.

Zdroje