TextReader.ReadLineAsync Method

Definition

异步读取一行字符并将数据作为字符串返回。Reads a line of characters asynchronously and returns the data as a string.

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

Returns

Task<String>

表示异步读取操作的任务。A task that represents the asynchronous read operation. TResult 参数的值包含来自文本读取器的下一行或为 null(如已读取所有字符)。The value of the TResult parameter contains the next line from the text reader, or is null if all of the characters have been read.

Attributes

Exceptions

下一行中的字符数大于 MaxValueThe number of characters in the next line is larger than MaxValue.

文本读取器已被释放。The text reader has been disposed.

以前的读取操作当前正在使用读取器。The reader is currently in use by a previous read operation.

Remarks

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

如果当前 TextReader 表示 Console.In 属性返回的标准输入流,则 ReadLineAsync 方法同步执行,而不是以异步方式执行。If the current TextReader represents the standard input stream returned by the Console.In property, the ReadLineAsync method executes synchronously rather than asynchronously.

Applies to

See also