StringReader(String) Konstruktor

Definice

Inicializuje novou instanci StringReader třídy, která čte ze zadaného řetězce.

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

Parametry

s
String

Řetězec, do kterého StringReader má být inicializován.

Výjimky

Parametr s je null.

Příklady

Tento příklad kódu je součástí většího příkladu uvedeného pro třídu StringReader.

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

Poznámky

Následující tabulka uvádí příklady jiných typických nebo souvisejících vstupně-výstupních úloh.

Chcete-li to provést... Podívejte se na příklad v tomto tématu...
Vytvořte textový soubor. Postupy: Zápis textu do souboru
Zápis do textového souboru Postupy: Zápis textu do souboru
Čtení z textového souboru Postupy: Čtení textu ze souboru
Připojte text k souboru. Postupy: Otevření a připojení k souboru protokolu

File.AppendText

FileInfo.AppendText
Získejte velikost souboru. FileInfo.Length
Získá atributy souboru. File.GetAttributes
Nastavte atributy souboru. File.SetAttributes
Určete, jestli soubor existuje. File.Exists
Čtení z binárního souboru Postupy: Čtení a zápis do nově vytvořeného datového souboru
Zápis do binárního souboru Postupy: Čtení a zápis do nově vytvořeného datového souboru

Platí pro

Viz také