Console.ReadLine() Method

Reads text from the console input field. The 'Button' argument specifies which button set is displayed. Returns an answer indicating which button was pressed to end input. The input text is available in the Console.LastReadResult property.

Syntax

Console.ReadLine(Prompt, Buttons, [WebTimeout])

The method syntax has these parts:

Part Description
Prompt (String) Prompt message displayed above the input field, blinking.
Buttons (Buttons) Selects the button configuration to use during input. See the Buttons constants.
WebTimeout (Long) Timeout for the web virtual console (seconds, default 300) See note below
Return (Answers)

Remarks

This method allows you to gather typed input from the user. The prompt parameter passes a string that is displayed above the input box, blinking to draw attention to it. The Button parameter allows you to select from several pushbutton configurations as shown below. Use the LastReadResult property to retrieve the typed input. For the web virtual console, a third optional parameter WebTimeout may be supplied. See below.

This method will raise an error after 300 seconds if the request comes from the web and the user does not respond within this interval. The timeout can be modified by including the optional WebTimeout parameter in the call.

WebTimeout Notes

Symbolic Constants

The (symbolic) values for Answers are:

Constant Value Description
consCancel 13 The console Cancel button was pressed.
consNo 11 The console No button was pressed.
consOK 12 The console OK button was pressed.
consYes 10 The console Yes button was pressed.

The (symbolic) values for Buttons are:

Constant Value Description
consOkCancel 1 Show the OK and Cancel buttons.
consOkOnly 3 Show only the OK button.
consYesNo 2 Show the Yes and No buttons