StringWriter.Write Metodo

Definizione

Scrive dati nella stringa.

Overload

Write(Char[], Int32, Int32)

Scrive una sottomatrice di caratteri nella stringa.

Write(String)

Scrive una stringa nella stringa corrente.

Write(StringBuilder)

Scrive nella stringa corrente la rappresentazione stringa di un generatore di stringhe.

Write(Char)

Scrive un carattere nella stringa.

Write(ReadOnlySpan<Char>)

Scrive la rappresentazione stringa di un intervallo di caratteri nella stringa corrente.

Write(Char[], Int32, Int32)

Origine:
StringWriter.cs
Origine:
StringWriter.cs
Origine:
StringWriter.cs

Scrive una sottomatrice di caratteri nella stringa.

public:
 override void Write(cli::array <char> ^ buffer, int index, int count);
public override void Write (char[] buffer, int index, int count);
override this.Write : char[] * int * int -> unit
Public Overrides Sub Write (buffer As Char(), index As Integer, count As Integer)

Parametri

buffer
Char[]

Matrice di caratteri da cui scrivere i dati.

index
Int32

Posizione del carattere nel buffer da cui iniziare la lettura dei dati.

count
Int32

Numero massimo di caratteri da scrivere.

Eccezioni

buffer è null.

index o count è negativo.

(index + count)>buffer. Length.

Il writer viene chiuso.

Esempio

Questo esempio di codice fa parte di un esempio più grande fornito per il StringWriter() costruttore.

// Use the three overloads of the Write method that are 
// overridden by the StringWriter class.
strWriter->Write( "file path characters are: " );
strWriter->Write( Path::InvalidPathChars, 0, Path::InvalidPathChars->Length );
strWriter->Write( Char::Parse( "." ) );
// Use the three overloads of the Write method that are
// overridden by the StringWriter class.
strWriter.Write("file path characters are: ");
strWriter.Write(
    Path.InvalidPathChars, 0, Path.InvalidPathChars.Length);
strWriter.Write('.');
' Use the three overloads of the Write method that are 
' overridden by the StringWriter class.
strWriter.Write("file path characters are: ")
strWriter.Write( _
    Path.InvalidPathChars, 0, Path.InvalidPathChars.Length)
strWriter.Write("."C)

Commenti

Questo metodo esegue l'override di TextWriter.Write.

Questo metodo scrive count i caratteri dei dati in questo StringWriter oggetto da , a partire dalla bufferposizione index.

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
Ottenere 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

Vedi anche

Si applica a

Write(String)

Origine:
StringWriter.cs
Origine:
StringWriter.cs
Origine:
StringWriter.cs

Scrive una stringa nella stringa corrente.

public:
 override void Write(System::String ^ value);
public override void Write (string value);
public override void Write (string? value);
override this.Write : string -> unit
Public Overrides Sub Write (value As String)

Parametri

value
String

Stringa da scrivere.

Eccezioni

Il writer viene chiuso.

Esempio

Questo esempio di codice fa parte di un esempio più grande fornito per la StringWriter classe.

convertedCharacter = Convert::ToChar( intCharacter );
if ( convertedCharacter == '.' )
{
   strWriter->Write(  ".\n\n" );
   
   // Bypass the spaces between sentences.
   strReader->Read();
   strReader->Read();
}
convertedCharacter = (char)intCharacter;
if(convertedCharacter == '.')
{
    strWriter.Write(".\n\n");

    // Bypass the spaces between sentences.
    strReader.Read();
    strReader.Read();
}
convertedCharacter = Convert.ToChar(intCharacter)
If convertedCharacter = "."C Then
    strWriter.Write("." & vbCrLf & vbCrLf)

    ' Bypass the spaces between sentences.
    strReader.Read()
    strReader.Read()

Commenti

Questo metodo esegue l'override di TextWriter.Write.

Se la stringa specificata è null, non viene scritto nulla.

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
Ottenere 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

Vedi anche

Si applica a

Write(StringBuilder)

Origine:
StringWriter.cs
Origine:
StringWriter.cs
Origine:
StringWriter.cs

Scrive nella stringa corrente la rappresentazione stringa di un generatore di stringhe.

public:
 override void Write(System::Text::StringBuilder ^ value);
public override void Write (System.Text.StringBuilder? value);
override this.Write : System.Text.StringBuilder -> unit
Public Overrides Sub Write (value As StringBuilder)

Parametri

value
StringBuilder

Generatore di stringhe da scrivere nella stringa.

Si applica a

Write(Char)

Origine:
StringWriter.cs
Origine:
StringWriter.cs
Origine:
StringWriter.cs

Scrive un carattere nella stringa.

public:
 override void Write(char value);
public override void Write (char value);
override this.Write : char -> unit
Public Overrides Sub Write (value As Char)

Parametri

value
Char

Carattere da scrivere.

Eccezioni

Il writer viene chiuso.

Esempio

Questo esempio di codice fa parte di un esempio più grande fornito per il StringWriter() costruttore.

// Use the three overloads of the Write method that are 
// overridden by the StringWriter class.
strWriter->Write( "file path characters are: " );
strWriter->Write( Path::InvalidPathChars, 0, Path::InvalidPathChars->Length );
strWriter->Write( Char::Parse( "." ) );
// Use the three overloads of the Write method that are
// overridden by the StringWriter class.
strWriter.Write("file path characters are: ");
strWriter.Write(
    Path.InvalidPathChars, 0, Path.InvalidPathChars.Length);
strWriter.Write('.');
' Use the three overloads of the Write method that are 
' overridden by the StringWriter class.
strWriter.Write("file path characters are: ")
strWriter.Write( _
    Path.InvalidPathChars, 0, Path.InvalidPathChars.Length)
strWriter.Write("."C)

Commenti

Questo metodo esegue l'override di TextWriter.Write.

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
Ottenere 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

Vedi anche

Si applica a

Write(ReadOnlySpan<Char>)

Origine:
StringWriter.cs
Origine:
StringWriter.cs
Origine:
StringWriter.cs

Scrive la rappresentazione stringa di un intervallo di caratteri nella stringa corrente.

public:
 override void Write(ReadOnlySpan<char> buffer);
public override void Write (ReadOnlySpan<char> buffer);
override this.Write : ReadOnlySpan<char> -> unit
Public Overrides Sub Write (buffer As ReadOnlySpan(Of Char))

Parametri

buffer
ReadOnlySpan<Char>

Intervallo di caratteri da scrivere nella stringa.

Si applica a