input - Multiple lines iput from console in c# -
i trying read values in c# console , processing them. stuck @ error.
the input console is:
name:abcd school:xyz marks:80 //here user enters new line before entering new info 1 time again name:ab school:xyz marks:90 //new line 1 time again name:ab school:xyz marks:90 and on. not know before hand number of console inputs...how can observe user has stopped entering & store input.
i tried using
string line; while((line=console.readline())!=null) { //but here seems infinite loop } any suggestions
your code looks "end of console input" "ctrl+z" covered in console.readline:
if ctrl+z character pressed when method reading input console, method returns null. enables user prevent farther keyboard input when readline method called in loop. next illustration illustrates scenario.
if looking empty string completion utilize string.isnullorwhitespace.
string line; while(!string.isnullorwhitespace(line=console.readline())) { //but here seems infinite loop } c# input command-line console-application
No comments:
Post a Comment