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


using System.Runtime.InteropServices;

 

可以实现控制台的隐藏或者显示