Last Updated : 11 Jul, 2025
Console.SetWindowSize(Int32, Int32) Method is used to change the height and width of the console window to the specified values.
Syntax: public static void SetWindowSize (int width, int height); Parameters: width: The width of the console window measured in columns. height: The height of the console window measured in rows.
Exceptions:
Example 1: Getting the current dimensions of the window.
csharp
// C# program to get the current
// window width and Height
using System;
namespace GFG {
class Program {
static void Main(string[] args)
{
Console.WriteLine(Console.WindowWidth);
Console.WriteLine(Console.WindowHeight);
}
}
}
Output: Example 2: Setting the value of SetWindowSize
csharp
// C# program to illustrate the
// Console.SetWindowSize Property
using System;
namespace GFG {
class Program {
static void Main(string[] args)
{
// Passed 40, 40 to SetWindowSize to
// change window size to 40 by 40
Console.SetWindowSize(40, 40);.
// Printing the current dimensions
Console.WriteLine(Console.WindowWidth);
Console.WriteLine(Console.WindowHeight);
}
}
}
Output: Note: See the Horizontal Scroll Bar at the bottom of the Window in both the images. Reference:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4