天天看点

C#在winform中调用系统控制台输出

用win32 API函数实现:

[DllImport("kernel32.dll")]
static extern bool FreeConsole();
[DllImport("kernel32.dll")]
public static extern bool AllocConsole();      

加入上面的代码后,我们直接就用 输出的代码就行了 Console.WriteLine(“试试”);