Although seem lie, in the C# language not exist a dialog box for ask a data. If you don’t want create your own dialog box and don’t need personalize it, you can use the sentence Inputbox that you can find in Microsoft.VisualBasic assembly.
This sentence show a modal dialog with a label, text box, a button accept and other button for cancel.

The definition of sentence InputBox is as follow:

  • Prompt: Dialog message
  • Title: Optional. Dialog title.
  • DefaultResponse: Optional. answer by default.
  • xPos: Optional. Coordinate X, centered by default.
  • yPos: Optional. Coordinate Y, centered by default.

Steps for insert an InputBox in C#:

1. Insert a reference to Microsoft.VisualBasic assembly:

How to insert an InputBox in C# - 1

How to insert an InputBox in C# - 2

2. Insert the sentence:

Note: if the user cancels the dialog then the statement returns an empty string


How to insert an InputBox in C# - 3