Windows application opens the console and writes to it

How can I open a console in a Windows C # graphical application and then write some data to the console. Can I even open the console from the win app?

+4
source share
3 answers

Go to Win32. AllocConsole ()

+2
source

Say you have a winform application in visual studio. Go to "Project Properties"> "Application" tab> "Enter output type:" in the console application.

Now, when you start your winform, the console application lights up in the background. You can write this console application with standard output. For instance.

private void button1_Click(object sender, EventArgs e) { Console.WriteLine("Hello World"); } 
+4
source

Instructions are here .

1st result for Google: c# write console .

Incredibly, this is the least documented and most useful in C #.

-6
source

Source: https://habr.com/ru/post/1313415/


All Articles