用win32 API函数实现:
[DllImport("kernel32.dll")]
static extern bool FreeConsole();
[DllImport("kernel32.dll")]
public static extern bool AllocConsole();
加入上面的代码后,我们直接就用 输出的代码就行了 Console.WriteLine(“试试”);
来自文章:https://www.cnblogs.com/seayxu/p/4643306.html