title: winforms output to commandline
body: <p>I have a winforms application. I would like to run the .exe from the commandline and redirect the output from one of the output textboxes to the commandline. I don't want to launch the winform application just run the logic in the background.  </p>
  
  <p>I tried the advice from this thread</p>
  
  <p><a href="https://stackoverflow.com/questions/7198639/c-sharp-application-both-gui-and-commandline">C# application both GUI and commandline</a></p>
  
  <p>but I didn't see any of my console.writeline messages in the command line in cmd.exe when I ran the application via the cmd.exe. Can anyone guide me as to what I might be doing wrong?</p>
  
  <p>I have an if statement that did this logic:</p>
  
  <pre><code>  if(args.Length &gt;0)
     {
       Console.writeline("this has arguments");
       new Mainform();
     }
    else
     {
      Application.EnableVisualStyles();
      Application.Run(new MainForm());
     }
  </code></pre>
  
  <p>The else part still works. But nothing happens in the if part either using the cmd.exe to run the application or when I use the properties ->debug->command line arguments and give it arguments to run while debugging it. I have no idea what I am doing wrong. </p>