csharp create console for winform

Code Example - csharp create console for winform

                
                        //you normally cant add a console in a winform project but heres how to do it programmatically so you can
     [DllImport("kernel32.dll", SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        //allocate console, call AllocateConsole to start the console
        public static extern bool AllocConsole();

        //use this function when your application starts + when you want to update the console
        public static void Update(string title, string message)
        {
            Console.Title = title;
            Console.WriteLine(message);
        }