Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
ReadLineAsync() |
Reads a line of characters asynchronously and returns the data as a string. |
ReadLineAsync(CancellationToken) |
Reads a line of characters asynchronously and returns the data as a string. |
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();
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>
[<System.Runtime.InteropServices.ComVisible(false)>]
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)
A task that represents the asynchronous read operation. 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.
The number of characters in the next line is larger than Int32.MaxValue.
The text reader has been disposed.
The reader is currently in use by a previous read operation.
The TextReader class is an abstract class. Therefore, you do not instantiate it in your code. For an example of using the ReadLineAsync method, see the StreamReader.ReadLineAsync method.
If the current TextReader represents the standard input stream returned by the Console.In property, the ReadLineAsync method executes synchronously rather than asynchronously.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by ReadLine().
Product | Versions |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
Reads a line of characters asynchronously and returns the data as a string.
public:
virtual System::Threading::Tasks::ValueTask<System::String ^> ReadLineAsync(System::Threading::CancellationToken cancellationToken);
public virtual System.Threading.Tasks.ValueTask<string?> ReadLineAsync(System.Threading.CancellationToken cancellationToken);
abstract member ReadLineAsync : System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<string>
override this.ReadLineAsync : System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<string>
Public Overridable Function ReadLineAsync (cancellationToken As CancellationToken) As ValueTask(Of String)
The token to monitor for cancellation requests.
A value task that represents the asynchronous read operation. 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.
The number of characters in the next line is larger than Int32.MaxValue.
The text reader has been disposed.
The reader is currently in use by a previous read operation.
The cancellation token was canceled. This exception is stored into the returned task.
The TextReader class is an abstract class. Therefore, you do not instantiate it in your code. For an example of using the ReadLineAsync(CancellationToken) method, see the ReadLineAsync(CancellationToken) method.
If the current TextReader represents the standard input stream returned by
the Console.In
property, the ReadLineAsync(CancellationToken) method
executes synchronously rather than asynchronously.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by ReadLine().
Product | Versions |
---|---|
.NET | 7, 8, 9, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in