Created
July 7, 2017 14:25
-
-
Save EtherZa/742c43b4c176fa893b5c6a7273e63250 to your computer and use it in GitHub Desktop.
Output to console in Windows Forms application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ShowConsole | |
{ | |
using System; | |
using System.Runtime.InteropServices; | |
using System.Windows.Forms; | |
public static class Program | |
{ | |
[DllImport("kernel32.dll", SetLastError = true)] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
public static extern bool AllocConsole(); | |
[STAThread] | |
public static void Main() | |
{ | |
Program.AllocConsole(); | |
Console.WriteLine("Hello world"); | |
Application.EnableVisualStyles(); | |
Application.SetCompatibleTextRenderingDefault(false); | |
Application.Run(new Form1()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment