I'm using CSharpCodeProvider class to compile c# code.
for example the code is,
using System;
namespace Foo
{
public class Bar
{
static void Main(string[] args)
{
Bar.SayHello();
Console.ReadLine();
}
public static void SayHello()
{
Console.WriteLine("Hello World");
}
}
}
What I want is to get the final string output after execution, in this case "Hello World". The object of CompilerResults which is returned has an output field but it online shows messages about compilation process. The output file with .exe extension is also created just fine and It shows that string.
I'm looking for either a way to extract that string from exe file generated, or any other way.
EDIT: Is there a way to get the output string WITHOUT running that process and extracting it from there?