This documentation is archived and is not being maintained.

Console.SetWindowSize Method

Sets the height and width of the console window to the specified values.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public static function SetWindowSize(
	width : int, 
	height : int


Type: System.Int32

The width of the console window measured in columns.

Type: System.Int32

The height of the console window measured in rows.


width or height is less than or equal to zero.


width plus WindowLeft or height plus WindowTop is greater than or equal to Int16.MaxValue.


width or height is greater than the largest possible window width or height for the current screen resolution and console font.


The user does not have permission to perform this action.


An I/O error occurred.

This example demonstrates the SetWindowSize method, and the WindowWidth and WindowHeight properties. You must run the example to see the full effect of changing the console window size.

The example reports the dimensions of a console window set to 85 columns and 43 rows, then waits for a key to be pressed. When any key is pressed, the dimensions of the console window are halved, the new dimensions are reported, and the example waits for another key press. Finally, when any key is pressed, the console window is restored to its original dimensions and the example terminates.

No code example is currently available or this language may not be supported.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0