StringReader(String) Constructor

Definición

Inicializa una nueva instancia de la clase StringReader que lee en la cadena especificada.

public:
 StringReader(System::String ^ s);
public StringReader (string s);
new System.IO.StringReader : string -> System.IO.StringReader
Public Sub New (s As String)

Parámetros

s
String

Cadena en la que StringReader debe inicializarse.

Excepciones

El parámetro s es null.

Ejemplos

Este ejemplo de código es parte de un ejemplo mayor proporcionado para la clase StringReader.

// From textReaderText, create a continuous paragraph 
// with two spaces between each sentence.
   String^ aLine;
String^ aParagraph;
StringReader^ strReader = gcnew StringReader( textReaderText );
while ( true )
{
   aLine = strReader->ReadLine();
   if ( aLine != nullptr )
   {
      aParagraph = String::Concat( aParagraph, aLine,  " " );
   }
   else
   {
      aParagraph = String::Concat( aParagraph,  "\n" );
      break;
   }
}

Console::WriteLine(  "Modified text:\n\n{0}", aParagraph );
// From textReaderText, create a continuous paragraph
// with two spaces between each sentence.
string aLine, aParagraph = null;
StringReader strReader = new StringReader(textReaderText);
while(true)
{
    aLine = strReader.ReadLine();
    if(aLine != null)
    {
        aParagraph = aParagraph + aLine + " ";
    }
    else
    {
        aParagraph = aParagraph + "\n";
        break;
    }
}
Console.WriteLine("Modified text:\n\n{0}", aParagraph);
' From textReaderText, create a continuous paragraph 
' with two spaces between each sentence.
Dim aLine, aParagraph As String
Dim strReader As New StringReader(textReaderText)
While True
    aLine = strReader.ReadLine()
    If aLine Is Nothing Then
        aParagraph = aParagraph & vbCrLf
        Exit While
    Else
        aParagraph = aParagraph & aLine & " "
    End If
End While
Console.WriteLine("Modified text:" & vbCrLf & vbCrLf & _ 
    aParagraph)

Comentarios

En la tabla siguiente se enumeran ejemplos de otras tareas de E/S típicas o relacionadas.

Para... Vea el ejemplo de este tema...
Crear un archivo de texto Cómo: Escribir texto en un archivo
Escribir en un archivo de texto. Cómo: Escribir texto en un archivo
Lee desde un archivo de texto. Cómo: Leer texto de un archivo
Anexar texto a un archivo. Cómo: Abrir y anexar a un archivo de registro

File.AppendText

FileInfo.AppendText
Obtiene el tamaño de un archivo. FileInfo.Length
Obtenga los atributos de un archivo. File.GetAttributes
Establezca los atributos de un archivo. File.SetAttributes
Determine si existe un archivo. File.Exists
Lee desde un archivo binario. Cómo: Leer y escribir en un archivo de datos recién creado
Escriba en un archivo binario. Cómo: Leer y escribir en un archivo de datos recién creado

Se aplica a

Consulte también