c# convert console.writeline to a string -


i want code takes text written on console , put on string variable, plz. this:

string s = console.writeline(invoke(o, null)); 

i want console because if invoke without can't text it.

i hope understand it.

you can't directly. think can somehow getting console window object or that, it's not worth time when want output of console.writeline.

there lot of overloads of console.writeline, in end overloads convert parameter string, using tostring. so, put output of console.writeline in string variable, call tostring on argument.

string s = invoke(o, null).tostring(); 

what if want both print, and store output? can this:

string s = invoke(o, null).tostring(); console.writeline(s); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -