Even in a Windows Forms application the console is there and you can start writing using System.Console
, possibly based on a commandline option like you mention, or a configuration switch, or whatever. Starting your application from a console window prompt will open your GUI like normal and the console output will be shown in the console like you expect. You can even still redirect that console output to a file for instance. Maybe that's enough for you?
Actually starting to show a console window from your Windows Forms application is something else. Not completely sure how to do it (if even possible). I'd look into starting a cmd
instance, possibly using System.Diagnostics.Process
to start a process while redirecting stdin
/stdout
/stderr
of that new process?
This is just speculation on my part at the moment though. Maybe some of the other answers will help here?