How to Capture Console Output from CSharpScript Evaluation

Viewed 92
var code = "return 1 + 2"; 
var result = await CSharpScript.EvaluateAsync(code, _scriptOptions);

// "result" is 3.
var code = "Console.WriteLine(\"Hello World\");"; 
var result = await CSharpScript.EvaluateAsync(code, _scriptOptions);

// "result" is null

In the second example, the Console.WriteLine() is evaluated and literally written to console. How can evaluate so it returns the string instead?

0 Answers
Related