Use a MessageBox to get a user input?

c#

Solution

You can use the VB.Net InputBox, directly from C#

string input = 
    Microsoft.VisualBasic.Interaction.InputBox("My Prompt", 
                                               "The Title", 
                                               "Desired Default", 
                                               -1, -1);
int listSize;
bool success = int.TryParse(input, out listSize);

You will probably need to add an appropriate reference to your project.

Problem

Sorry for the strange suggestion in the title... I'm looking to try and get a single piece of information from a user, and I was wondering if there was a variant of `MessageBox` that would grab a single piece of data, like a number as a parameter for a list size. ``` int listSize = Convert.ToInt32(MessageBox.TextBox.Text); ``` I don't really want to go through the effort of creating a tiny form for this single purpose if I can avoid it.

Original source