Console.SetWindowSize Method (Int32, Int32)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

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

static member SetWindowSize : 
        width:int *
        height:int -> unit

Parameters

width
Type: System.Int32

The width of the console window measured in columns.

height
Type: System.Int32

The height of the console window measured in rows.

Exception Condition
ArgumentOutOfRangeException

width or height is less than or equal to zero.

-or-

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

-or-

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

SecurityException

The user does not have permission to perform this action.

IOException

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.

UIPermission

for modifying safe top-level windows and subwindows. Associated enumeration: UIPermissionWindow.SafeTopLevelWindows

.NET Framework
Available since 2.0
Return to top
Show: