用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