I have an application that is implementing its own C# console (via Roslyn's scripting engine). I already got the code to execute a statement and got the possible return value and now I would like to output a "nice" string to the console. The trivial approach to call "ToString()" will usually have very human unreadable output.
The best solution for me would be to have the same kind of inspection output that the "Immediate Window" of Visual Studio uses.
So for example if my statement evaluates to a new string[]{"asd"}, then just calling ToString() would give me
System.String[]
where I would like to have the equivalent output of the Immediate Window - something like this:
{string[1]}
[0]: "asd"
So does anyone knows how to call the same convertion that the Immediate Window uses?
It appears you have an array of Strings containing a single String, and you call .ToString() against the array. Try to replace
.ToString()
with
[0].ToString()
and see if that would give you the expected result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With