TextWriter.WriteLineAsync 方法

定义

以异步形式将数据写入文本流,后跟行终止符。Asynchronously writes data to the text stream, followed by a line terminator.

重载

WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken)

以异步形式将字符内存区域的文本表示形式写入文本流,后跟行终止符。Asynchronously writes the text representation of a character memory region to the text stream, followed by a line terminator.

WriteLineAsync(String)

以异步形式将字符串写入文本流,后跟行终止符。Asynchronously writes a string to the text stream, followed by a line terminator.

WriteLineAsync(Char[])

以异步形式将字符数组写入文本流,后跟行终止符。Asynchronously writes an array of characters to the text stream, followed by a line terminator.

WriteLineAsync(StringBuilder, CancellationToken)

以异步形式将字符串生成器的文本表示形式写入文本流,后跟行终止符。Asynchronously writes the text representation of a string builder to the text stream, followed by a line terminator.

WriteLineAsync()

以异步形式将行终止符写入文本流。Asynchronously writes a line terminator to the text stream.

WriteLineAsync(Char)

以异步形式将字符写入文本流,后跟行终止符。Asynchronously writes a character to the text stream, followed by a line terminator.

WriteLineAsync(Char[], Int32, Int32)

以异步形式将字符子数组写入文本流,后跟行终止符。Asynchronously writes a subarray of characters to the text stream, followed by a line terminator.

注解

TextWriter 类是抽象类。The TextWriter class is an abstract class. 因此,不要在代码中对其进行实例化。Therefore, you do not instantiate it in your code. 有关使用WriteLineAsync方法的示例, StreamWriter.WriteLineAsync请参见方法。For an example of using the WriteLineAsync method, see the StreamWriter.WriteLineAsync method.

WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken)

以异步形式将字符内存区域的文本表示形式写入文本流,后跟行终止符。Asynchronously writes the text representation of a character memory region to the text stream, followed by a line terminator.

public virtual System.Threading.Tasks.Task WriteLineAsync (ReadOnlyMemory<char> buffer, System.Threading.CancellationToken cancellationToken = null);
abstract member WriteLineAsync : ReadOnlyMemory<char> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.WriteLineAsync : ReadOnlyMemory<char> * System.Threading.CancellationToken -> System.Threading.Tasks.Task

参数

buffer
ReadOnlyMemory<Char>

要写入文本流中的字符内存区域。The character memory region to write to the text stream.

cancellationToken
CancellationToken

要监视取消请求的标记。The token to monitor for cancellation requests. 默认值为 NoneThe default value is None.

返回

表示异步写入操作的任务。A task that represents the asynchronous write operation.

注解

行终止符由CoreNewLine字段定义。The line terminator is defined by the CoreNewLine field.

WriteLineAsync(String)

以异步形式将字符串写入文本流,后跟行终止符。Asynchronously writes a string to the text stream, followed by a line terminator.

public:
 virtual System::Threading::Tasks::Task ^ WriteLineAsync(System::String ^ value);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual System.Threading.Tasks.Task WriteLineAsync (string value);
abstract member WriteLineAsync : string -> System.Threading.Tasks.Task
override this.WriteLineAsync : string -> System.Threading.Tasks.Task
Public Overridable Function WriteLineAsync (value As String) As Task

参数

value
String

要写入的字符串。The string to write. 如果值为 null,则只写入行终止符。If the value is null, only a line terminator is written.

返回

表示异步写入操作的任务。A task that represents the asynchronous write operation.

属性

异常

文本编写器已被释放。The text writer is disposed.

文本编写器正在由其前一次写操作使用。The text writer is currently in use by a previous write operation.

注解

行终止符由CoreNewLine字段定义。The line terminator is defined by the CoreNewLine field.

TextWriter 类是抽象类。The TextWriter class is an abstract class. 因此,不要在代码中对其进行实例化。Therefore, you do not instantiate it in your code. 有关使用WriteLineAsync方法的示例, StreamWriter.WriteLineAsync请参见方法。For an example of using the WriteLineAsync method, see the StreamWriter.WriteLineAsync method.

另请参阅

WriteLineAsync(Char[])

以异步形式将字符数组写入文本流,后跟行终止符。Asynchronously writes an array of characters to the text stream, followed by a line terminator.

public:
 System::Threading::Tasks::Task ^ WriteLineAsync(cli::array <char> ^ buffer);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task WriteLineAsync (char[] buffer);
member this.WriteLineAsync : char[] -> System.Threading.Tasks.Task
Public Function WriteLineAsync (buffer As Char()) As Task

参数

buffer
Char[]

要写入文本流中的字符数组。The character array to write to the text stream. 如果字符数组为 null,则仅写入行结束符。If the character array is null, only the line terminator is written.

返回

表示异步写入操作的任务。A task that represents the asynchronous write operation.

属性

异常

文本编写器已被释放。The text writer is disposed.

文本编写器正在由其前一次写操作使用。The text writer is currently in use by a previous write operation.

注解

行终止符由CoreNewLine字段定义。The line terminator is defined by the CoreNewLine field.

另请参阅

WriteLineAsync(StringBuilder, CancellationToken)

以异步形式将字符串生成器的文本表示形式写入文本流,后跟行终止符。Asynchronously writes the text representation of a string builder to the text stream, followed by a line terminator.

public virtual System.Threading.Tasks.Task WriteLineAsync (System.Text.StringBuilder value, System.Threading.CancellationToken cancellationToken = null);
abstract member WriteLineAsync : System.Text.StringBuilder * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.WriteLineAsync : System.Text.StringBuilder * System.Threading.CancellationToken -> System.Threading.Tasks.Task

参数

value
StringBuilder

要作为字符串生成器写入文本流的字符串。The string, as a string builder, to write to the text stream.

cancellationToken
CancellationToken

要监视取消请求的标记。The token to monitor for cancellation requests. 默认值为 NoneThe default value is None.

返回

表示异步写入操作的任务。A task that represents the asynchronous write operation.

注解

行终止符由CoreNewLine字段定义。The line terminator is defined by the CoreNewLine field.

WriteLineAsync()

以异步形式将行终止符写入文本流。Asynchronously writes a line terminator to the text stream.

public:
 virtual System::Threading::Tasks::Task ^ WriteLineAsync();
[System.Runtime.InteropServices.ComVisible(false)]
public virtual System.Threading.Tasks.Task WriteLineAsync ();
abstract member WriteLineAsync : unit -> System.Threading.Tasks.Task
override this.WriteLineAsync : unit -> System.Threading.Tasks.Task
Public Overridable Function WriteLineAsync () As Task

返回

表示异步写入操作的任务。A task that represents the asynchronous write operation.

属性

异常

文本编写器已被释放。The text writer is disposed.

文本编写器正在由其前一次写操作使用。The text writer is currently in use by a previous write operation.

注解

行终止符由CoreNewLine字段定义。The line terminator is defined by the CoreNewLine field.

另请参阅

WriteLineAsync(Char)

以异步形式将字符写入文本流,后跟行终止符。Asynchronously writes a character to the text stream, followed by a line terminator.

public:
 virtual System::Threading::Tasks::Task ^ WriteLineAsync(char value);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual System.Threading.Tasks.Task WriteLineAsync (char value);
abstract member WriteLineAsync : char -> System.Threading.Tasks.Task
override this.WriteLineAsync : char -> System.Threading.Tasks.Task
Public Overridable Function WriteLineAsync (value As Char) As Task

参数

value
Char

要写入文本流中的字符。The character to write to the text stream.

返回

表示异步写入操作的任务。A task that represents the asynchronous write operation.

属性

异常

文本编写器已被释放。The text writer is disposed.

文本编写器正在由其前一次写操作使用。The text writer is currently in use by a previous write operation.

注解

行终止符由CoreNewLine字段定义。The line terminator is defined by the CoreNewLine field.

TextWriter 类是抽象类。The TextWriter class is an abstract class. 因此,不要在代码中对其进行实例化。Therefore, you do not instantiate it in your code. 有关使用WriteLineAsync方法的示例, StreamWriter.WriteLineAsync请参见方法。For an example of using the WriteLineAsync method, see the StreamWriter.WriteLineAsync method.

另请参阅

WriteLineAsync(Char[], Int32, Int32)

以异步形式将字符子数组写入文本流,后跟行终止符。Asynchronously writes a subarray of characters to the text stream, followed by a line terminator.

public:
 virtual System::Threading::Tasks::Task ^ WriteLineAsync(cli::array <char> ^ buffer, int index, int count);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual System.Threading.Tasks.Task WriteLineAsync (char[] buffer, int index, int count);
abstract member WriteLineAsync : char[] * int * int -> System.Threading.Tasks.Task
override this.WriteLineAsync : char[] * int * int -> System.Threading.Tasks.Task
Public Overridable Function WriteLineAsync (buffer As Char(), index As Integer, count As Integer) As Task

参数

buffer
Char[]

要从中写出数据的字符数组。The character array to write data from.

index
Int32

在开始接收数据时缓存中的字符位置。The character position in the buffer at which to start retrieving data.

count
Int32

要写入的字符数。The number of characters to write.

返回

表示异步写入操作的任务。A task that represents the asynchronous write operation.

属性

异常

buffernullbuffer is null.

indexcount 大于缓冲区长度。The index plus count is greater than the buffer length.

indexcount 为负数。index or count is negative.

文本编写器已被释放。The text writer is disposed.

文本编写器正在由其前一次写操作使用。The text writer is currently in use by a previous write operation.

注解

行终止符由CoreNewLine字段定义。The line terminator is defined by the CoreNewLine field.

另请参阅

适用于