Allow prompting for user input
Something like this:
int age = Prompt<int> ("Your age");
and it would bring up a dialog asking the user to enter their age.
That would handle single values. For multiple values, maybe Tuple-style:
var data = Prompt<string,int,bool> ("Your name", "Your age", "I agree to the terms and conditions");
("Hello, " + data.Item1 + " of age " + data.Item2).Dump();
if (!data.Item3) "Please agree to the terms and conditions".Dump();
It should remember the last value entered. If the user hits Cancel, then it should throw a OperationCancelledException or something like that.
This works via Console.ReadLline and Util.ReadLine. See “What’s New” for more details.
-
Piotr - use Util.GetPasssword
-
Piotr Owsiak commented
Is there a way to ask for password in a way that it is not visible on the screen?
-
Elias commented
I don't like how Console.ReadLine makes the result pane scroll to the bottom. I like Thomas Levesque's suggestion to the Interaction.InputBox from Microsoft.VisualBasic
-
Matt commented
Look here:
http://stackoverflow.com/a/12006038/1016343
In the sections "Util.Readline" (input text) and "Displaying a messagebox" (message box input such as "Yes" or "No") you find examples. -
Bent Rasmussen commented
Thanks Joe!
-
Thomas Levesque commented
A possible workaround is to reference Microsoft.VisualBasic and use Interaction.InputBox... but a built-in solution would be better
-
andremoraes commented
once you'd an option to automation - will be cool indeed to provide simple user input
-
You know - I started prototyping this feature a while back and had the same thought - this is why the feature didn't make it into the recent build. Writing a dialog with the necessary type converters and that can elegantly handle default values is is quite awkward, too.
-
Peter H commented
I dunno ... I just solve this one by putting a constant at the top of the file
const int age = 55;
That works well enough for me and keeps LinqPad simple.
I cannot give this item my vote.