c# - parsing pasted text in console application -
i have console application made of c#
it allows user paste text following
aaaaa bbbbb ccccc
i know console.readline() wont take it, used console.in.readtoend()
string input = console.in.readtoend(); list<string> inputlist = input.split('\n').tolist();
i need parse input text line line above code works, after pasting, in order conintue, user has hit enter once, hit ctrl+z hit enter again.
im wondering if there better way requires hit enter key once
any suggestions?
thanks
in console if paste block of lines not executed immediately. if paste
aaaa bbbb cccc
nothing happens. once hit enter, read method starts doing it's job. , readline() returns after every new line. way it, , imo it's easiest way:
list<string> lines = new list<string>(); string line; while ((line = console.readline()) != null) { // either here each line separately or lines.add(line); } // of lines here
my first stackoverflow answer, feel excited.
Comments
Post a Comment