What is the C# version of VB.net's InputDialog?
There is no such thing: I recommend to write it for yourself and use it whenever you need.
You mean InputBox? Just look in the Microsoft.VisualBasic namespace.
C# and VB.Net share a common library. If one language can use it, so can the other.
There isn't one. If you really wanted to use the VB InputBox in C# you can. Just add reference to Microsoft.VisualBasic.dll and you'll find it there.
But I would suggest to not use it. It is ugly and outdated IMO.
Add a reference to Microsoft.VisualBasic, InputBox is in the Microsoft.VisualBasic.Interaction namespace:
string input = Microsoft.VisualBasic.Interaction.InputBox("Prompt", "Title", "Default", 0, 0);
Add reference to Microsoft.VisualBasic
and use this function:
string response = Microsoft.VisualBasic.Interaction.InputBox("What's 1+1?", "Title", "2", 0, 0);
The last 2 number is an X/Y position to display the input dialog.
To sum it up:
- There is none in C#.
You can use the dialog from Visual Basic by adding a reference to Microsoft.VisualBasic:
- In Solution Explorer right-click on the References folder.
- Select Add Reference...
- In the .NET tab select Microsoft.VisualBasic
- Click on OK
Then you can use the previously mentioned code:
string input = Microsoft.VisualBasic.Interaction.InputBox("Title", "Prompt", "Default", 0, 0);
- Write your own InputBox.
- Use someone else's.
That said, I suggest that you consider the need of an input box in the first place. Dialogs are not always the best way to do things and sometimes they do more harm than good - but that depends on the particular situation.