简体   繁体   English

Windows应用程序打开控制台并写入其中

[英]windows application open console and write in it

How can i open console in C# graphical windows application and then write some data in console. 如何在C#图形窗口应用程序中打开控制台,然后在控制台中写入一些数据。 Can i even open a console from win app? 我甚至可以从win app打开一个控制台吗?

Say you have a winform application in visual studio. 假设您在visual studio中有一个winform应用程序。 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. 现在,当您启动winform时,控制台应用程序将在后台触发。 You can write to this console application with standard out. 您可以使用标准输出写入此控制台应用程序。 EG 例如

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

Check into Win32. 检查Win32。 AllocConsole () AllocConsole ()

Instructions here . 这里的说明。

1st result for Google: c# write console . Google的第一个结果: c# write console

Incredibly, this is the least documented and most useful thing to do in C#. 令人难以置信的是,这是C#中记录最少且最有用的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM