Answers for "c# create console for winform"

C#
0

c# 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);
        }
Posted by: Guest on October-07-2021

C# Answers by Framework

Browse Popular Code Answers by Language