I am making a C# windows form application. I want Console.write() in my form application. I read lot of stuff. But did not work. Can you give me a clean code to achieve this ? Thanks in advance.
P.S.
[DllImport("kernel32.dll")]
static extern bool AttachConsole(int dwProcessId);
private const int ATTACH_PARENT_PROCESS = -1;
public Form1()
{
InitializeComponent();
AttachConsole(ATTACH_PARENT_PROCESS);
Console.WriteLine("This is from the main program");
}
This is not working for me.