StringReader(String) Constructor

Definición

Inicializa una nueva instancia de la StringReader clase que lee de 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 a la StringReader que se debe inicializar .

Excepciones

El s parámetro es null.

Ejemplos

Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la StringReader clase .

// 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 ello... Vea el ejemplo de este tema...
Cree 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
Anexe texto a un archivo. Cómo: Abrir y anexar a un archivo de registro

File.AppendText

FileInfo.AppendText
Obtenga el tamaño de un archivo. FileInfo.Length
Obtiene 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
Escribir en un archivo binario. Cómo: Leer y escribir en un archivo de datos recién creado

Se aplica a

Consulte también