您可以使用Windows API移动控制台窗口.使用DllImport声明要使用的WinApi函数:
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll", SetLastError = true)]
internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
Run Code Online (Sandbox Code Playgroud)
然后打电话给他们:例如
IntPtr ptr = GetConsoleWindow();
MoveWindow(ptr, 0, 0, 1000, 400, true);
Run Code Online (Sandbox Code Playgroud)
您可以使用进一步的WinApi函数SetWindowPos.您可以通过搜索Web PInvoke以及函数名称来查找DllImport语法.按照那里和MSDN中的说明进行操作.