Suppose you are writing a GUI application for Windows and you want to be able to debug your applicaiton by sending console output to a console window that opens only if you pass a certain command line argument or are compiled in debug mode. Console.WriteLine sends your output to nowhere very fast. If you want to have a console window, here is how you do it:
Inside one of your classes insert this reference to the AllocConsole method in kernel32.dll:
[DllImport("kernel32.dll")]
public static extern Int32 AllocConsole();
Now just call MyClass.AllocConsole() if you want a console for output and voila, there you go! All output to Console now appears in your console window.