开发者

windows application open console and write in it

开发者 https://www.devze.com 2023-01-04 09:56 出处:网络
How can i open console in C# graphical windows application and then write some data in 开发者_如何转开发console. Can i even open a console from win app?Say you have a winform application in visual stu

How can i open console in C# graphical windows application and then write some data in 开发者_如何转开发console. Can i even open a console from win app?


Say you have a winform application in visual studio. Go to the Project Properties > Application Tab > Change "Output Type:" to Console Application.

Now when you launch your winform a console application will fire in the background. You can write to this console application with standard out. E.G.

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


Check into Win32.AllocConsole()


Instructions here.

1st result for Google: c# write console.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号