CKTIS / C#
System.IO.StringReader: referencia práctica
System.IO.StringReader: referencia práctica: StringReader expone una cadena existente mediante el contrato TextReader.
Versión: .NET API; verified on .NET 10.0.14
Sintaxis
System.IO.StringReader /* select a documented member or constructor */StringReader expone una cadena existente mediante el contrato TextReader.
Úsalo para analizadores que esperan TextReader sin crear un archivo temporal.
ReadLine elimina el separador, Dispose termina el uso y todo el texto de origen ya está en memoria.
ReadLine devuelve null después del final. Un separador final termina la línea anterior y no crea otra línea vacía; un separador inicial o separadores consecutivos pueden producir una línea vacía.
El programa completo usa realmente System.IO.StringReader; su stdout esperado exacto es first.
Ejemplos
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());
Resultado
first
El programa completo usa realmente `System.IO.StringReader`; su stdout esperado exacto es `first`.