StreamWriter.Write Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Scrive i dati nel flusso.
Overload
| Nome | Descrizione |
|---|---|
| Write(String, Object, Object, Object) |
Scrive una stringa formattata nel flusso usando la stessa semantica del Format(String, Object, Object, Object) metodo . |
| Write(String, Object, Object) |
Scrive una stringa formattata nel flusso usando la stessa semantica del Format(String, Object, Object) metodo . |
| Write(Char[], Int32, Int32) |
Scrive una sottomaschera di caratteri nel flusso. |
| Write(String, ReadOnlySpan<Object>) |
Scrive una stringa formattata nel flusso usando la stessa semantica di Format(String, ReadOnlySpan<Object>). |
| Write(String, Object[]) |
Scrive una stringa formattata nel flusso usando la stessa semantica del Format(String, Object[]) metodo . |
| Write(ReadOnlySpan<Char>) |
Scrive un intervallo di caratteri nel flusso. |
| Write(String) |
Scrive una stringa nel flusso. |
| Write(Char[]) |
Scrive una matrice di caratteri nel flusso. |
| Write(Char) |
Scrive un carattere nel flusso. |
| Write(String, Object) |
Scrive una stringa formattata nel flusso usando la stessa semantica del Format(String, Object) metodo . |
Write(String, Object, Object, Object)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa formattata nel flusso usando la stessa semantica del Format(String, Object, Object, Object) metodo .
public:
override void Write(System::String ^ format, System::Object ^ arg0, System::Object ^ arg1, System::Object ^ arg2);
public override void Write(string format, object? arg0, object? arg1, object? arg2);
override this.Write : string * obj * obj * obj -> unit
Public Overrides Sub Write (format As String, arg0 As Object, arg1 As Object, arg2 As Object)
Parametri
- format
- String
Stringa di formato composito.
- arg0
- Object
Primo oggetto da formattare e scrivere.
- arg1
- Object
Secondo oggetto da formattare e scrivere.
- arg2
- Object
Terzo oggetto da formattare e scrivere.
Commenti
Vedere Write(String, Object, Object, Object) per una descrizione delle funzionalità di formattazione composita offerte.
Si applica a
Write(String, Object, Object)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa formattata nel flusso usando la stessa semantica del Format(String, Object, Object) metodo .
public:
override void Write(System::String ^ format, System::Object ^ arg0, System::Object ^ arg1);
public override void Write(string format, object? arg0, object? arg1);
override this.Write : string * obj * obj -> unit
Public Overrides Sub Write (format As String, arg0 As Object, arg1 As Object)
Parametri
- format
- String
Stringa di formato composito.
- arg0
- Object
Primo oggetto da formattare e scrivere.
- arg1
- Object
Secondo oggetto da formattare e scrivere.
Commenti
Vedere Write(String, Object, Object) per una descrizione delle funzionalità di formattazione composita offerte.
Si applica a
Write(Char[], Int32, Int32)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una sottomaschera di caratteri nel flusso.
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 contenente i dati da scrivere.
- index
- Int32
Posizione del carattere nel buffer in corrispondenza della quale iniziare la lettura dei dati.
- count
- Int32
Numero massimo di caratteri da scrivere.
Eccezioni
buffer è null.
La lunghezza del buffer meno index è minore di count.
index o count è negativo.
Si verifica un errore di I/O.
AutoFlush è true o il buffer è pieno e il StreamWriter writer corrente è chiuso.
AutoFlush è true o il StreamWriter buffer è pieno e il contenuto del buffer non può essere scritto nel flusso di dimensioni fisse sottostanti perché StreamWriter è alla fine del flusso.
Esempio
In questo esempio vengono scritti otto caratteri da una matrice di 13 elementi in un file, a partire dal terzo elemento della matrice.
using System;
using System.IO;
public class SWBuff
{
public static void Main(String[] args)
{
FileStream sb = new FileStream("MyFile.txt", FileMode.OpenOrCreate);
char[] b = {'a','b','c','d','e','f','g','h','i','j','k','l','m'};
StreamWriter sw = new StreamWriter(sb);
sw.Write(b, 3, 8);
sw.Close();
}
}
Imports System.IO
Public Class SWBuff
Public Shared Sub Main()
Dim sb As New FileStream("MyFile.txt", FileMode.OpenOrCreate)
Dim b As Char() = {"a"c, "b"c, "c"c, "d"c, "e"c, "f"c, "g"c, _
"h"c, "i"c, "j"c, "k"c, "l"c, "m"c}
Dim sw As New StreamWriter(sb)
sw.Write(b, 3, 8)
sw.Close()
End Sub
End Class
Commenti
Questo metodo esegue l'override di TextWriter.Write.
I caratteri vengono letti dall'inizio buffer e continuando fino a indexindex + (count - 1). Tutti i caratteri vengono scritti nel flusso sottostante, a meno che non venga raggiunta prematuramente la fine del flusso sottostante.
Flush viene richiamato automaticamente se AutoFlush è true.
Per un elenco delle attività di I/O comuni, vedere Attività di I/O comuni.
Vedi anche
Si applica a
Write(String, ReadOnlySpan<Object>)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa formattata nel flusso usando la stessa semantica di Format(String, ReadOnlySpan<Object>).
public:
override void Write(System::String ^ format, ReadOnlySpan<System::Object ^> arg);
public override void Write(string format, scoped ReadOnlySpan<object?> arg);
override this.Write : string * ReadOnlySpan<obj> -> unit
Public Overrides Sub Write (format As String, arg As ReadOnlySpan(Of Object))
Parametri
- format
- String
Stringa di formato composito.
- arg
- ReadOnlySpan<Object>
Intervallo di oggetti contenente zero o più oggetti da formattare e scrivere.
Si applica a
Write(String, Object[])
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa formattata nel flusso usando la stessa semantica del Format(String, Object[]) metodo .
public:
override void Write(System::String ^ format, ... cli::array <System::Object ^> ^ arg);
public override void Write(string format, params object?[] arg);
override this.Write : string * obj[] -> unit
Public Overrides Sub Write (format As String, ParamArray arg As Object())
Parametri
- format
- String
Stringa di formato composito.
- arg
- Object[]
Matrice di oggetti che contiene zero o più oggetti da formattare e scrivere.
Commenti
Vedere Write(String, Object[]) per una descrizione delle funzionalità di formattazione composita offerte.
Si applica a
Write(ReadOnlySpan<Char>)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive un intervallo di caratteri nel flusso.
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.
Si applica a
Write(String)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa nel flusso.
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 nel flusso. Se value è null, non viene scritto nulla.
Eccezioni
AutoFlush è true o il buffer è pieno e il StreamWriter writer corrente è chiuso.
AutoFlush è true o il StreamWriter buffer è pieno e il contenuto del buffer non può essere scritto nel flusso di dimensioni fisse sottostanti perché StreamWriter è alla fine del flusso.
Si verifica un errore di I/O.
Commenti
Questo metodo esegue l'override di TextWriter.Write.
L'oggetto specificato String viene scritto nel flusso sottostante, a meno che non venga raggiunta prematuramente la fine del flusso.
Flush viene richiamato automaticamente se AutoFlush è true. Se value è null, non vengono scritte voci.
Per un elenco delle attività di I/O comuni, vedere Attività di I/O comuni.
Vedi anche
Si applica a
Write(Char[])
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una matrice di caratteri nel flusso.
public:
override void Write(cli::array <char> ^ buffer);
public override void Write(char[] buffer);
public override void Write(char[]? buffer);
override this.Write : char[] -> unit
Public Overrides Sub Write (buffer As Char())
Parametri
- buffer
- Char[]
Matrice di caratteri contenente i dati da scrivere. Se buffer è null, non viene scritto nulla.
Eccezioni
Si verifica un errore di I/O.
AutoFlush è true o il buffer è pieno e il StreamWriter writer corrente è chiuso.
AutoFlush è true o il StreamWriter buffer è pieno e il contenuto del buffer non può essere scritto nel flusso di dimensioni fisse sottostanti perché StreamWriter è alla fine del flusso.
Commenti
Questo metodo esegue l'override di TextWriter.Write.
I caratteri specificati vengono scritti nel flusso sottostante, a meno che non venga raggiunta prematuramente la fine del flusso. Se AutoFlush è true, Flush viene richiamato automaticamente.
Questo metodo potrebbe offrire prestazioni più veloci di Write (char[],``int,``int) perché contiene meno argomenti da controllare.
Per un elenco delle attività di I/O comuni, vedere Attività di I/O comuni.
Vedi anche
Si applica a
Write(Char)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive un carattere nel flusso.
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 nel flusso.
Eccezioni
Si verifica un errore di I/O.
AutoFlush è true o il buffer è pieno e il StreamWriter writer corrente è chiuso.
AutoFlush è true o il StreamWriter buffer è pieno e il contenuto del buffer non può essere scritto nel flusso di dimensioni fisse sottostanti perché StreamWriter è alla fine del flusso.
Commenti
Questo metodo esegue l'override di TextWriter.Write.
Il carattere specificato viene scritto nel flusso sottostante, a meno che non venga raggiunta prematuramente la fine del flusso. Se AutoFlush è true, Flush viene richiamato automaticamente.
Per un elenco delle attività di I/O comuni, vedere Attività di I/O comuni.
Vedi anche
Si applica a
Write(String, Object)
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
- Origine:
- StreamWriter.cs
Scrive una stringa formattata nel flusso usando la stessa semantica del Format(String, Object) metodo .
public:
override void Write(System::String ^ format, System::Object ^ arg0);
public override void Write(string format, object? arg0);
override this.Write : string * obj -> unit
Public Overrides Sub Write (format As String, arg0 As Object)
Parametri
- format
- String
Stringa di formato composito.
- arg0
- Object
Oggetto da formattare e scrivere.
Commenti
Vedere Write(String, Object) per una descrizione delle funzionalità di formattazione composita offerte.