CKTIS / C#
System.IO.StringReader: riferimento pratico
System.IO.StringReader: riferimento pratico: StringReader espone una stringa esistente tramite il contratto TextReader.
Versione: .NET API; verified on .NET 10.0.14
Sintassi
System.IO.StringReader /* select a documented member or constructor */StringReader espone una stringa esistente tramite il contratto TextReader.
Usalo per parser che richiedono TextReader senza creare un file temporaneo.
ReadLine rimuove il separatore, Dispose termina l’uso e tutto il testo sorgente è già in memoria.
ReadLine restituisce null dopo la fine. Un separatore finale termina la riga precedente e non crea una riga vuota aggiuntiva; un separatore iniziale o separatori consecutivi possono produrre una riga vuota.
Il programma completo usa realmente System.IO.StringReader; lo stdout esatto atteso è first.
Esempi
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());
Risultato
first
Il programma completo usa realmente `System.IO.StringReader`; lo stdout esatto atteso è `first`.