StringReader(String) Costruttore

Definizione

Inizializza una nuova istanza della classe StringReader che legge dalla stringa specificata.

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

Parametri

s
String

Stringa sulla quale inizializzare StringReader.

Eccezioni

Il valore del parametro s è null.

Esempio

Questo esempio di codice fa parte di un esempio più ampio fornito per la StringReader classe .

// 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)

Commenti

Nella tabella seguente sono elencati esempi di altre attività di I/O tipiche o correlate.

Per eseguire questa operazione... Vedere l'esempio riportato in questo argomento...
Creare un file di testo. Procedura: Scrivere un testo in un file
Scrivere in un file di testo. Procedura: Scrivere un testo in un file
Leggere da un file di testo. Procedura: Leggere testo da un file
Aggiungere testo a un file. Procedura: Aprire e accodare un file di log

File.AppendText

FileInfo.AppendText
Ottenere le dimensioni di un file. FileInfo.Length
Ottiene gli attributi di un file. File.GetAttributes
Impostare gli attributi di un file. File.SetAttributes
Determinare se esiste un file. File.Exists
Leggere da un file binario. Procedura: Leggere e scrivere su un file di dati appena creato
Scrivere in un file binario. Procedura: Leggere e scrivere su un file di dati appena creato

Si applica a

Vedi anche