c# - Write out text to the console output as an input -
i'm writing console application c# , there question @ origin of program:
console.writeline("would create config folder? (y/n)");
i set default "y" after line, it's plenty user press enter. (or delete backspace if (s)he wants "n")
is possible? how?
the right behavior here should show like
console.writeline("would create config folder? (y/n) [y]");
this tells user y
default , pressing come in auto selected. think faster in case user want select n
because user don't have delete y
, come in his/ choice.
consider if user has go through multiple question , have select n
of them. little annoying.
simple way code (just pseudo-code) is:
boolean selection = true; //false if 'n' default if(userinput == 'n') selection = false;
if still want write changeable output use:
console.writeline("would create config folder? (y/n)"); sendkeys.sendwait("y"); console.readline();
c# .net console-application
No comments:
Post a Comment