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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -