title: How Console.write() in C# Windows Form Application
body: <p>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>
  
  <p>P.S.</p>
  
  <pre><code>[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");
  }
  </code></pre>
  
  <p>This is not working for me.</p>