C# Console WindowWidth
Description
Console WindowWidth
gets or sets the width of the console
window.
Syntax
Console.WindowWidth
has the following syntax.
public static int WindowWidth { get; set; }
Example
using System;//w w w. j a v a 2 s. c o m
class Sample
{
public static void Main()
{
int origWidth, width;
int origHeight, height;
origWidth = Console.WindowWidth;
origHeight = Console.WindowHeight;
Console.WriteLine(Console.WindowWidth);
Console.WriteLine(Console.WindowHeight);
Console.WriteLine("Press a key to continue");
Console.ReadKey(true);
width = origWidth/2;
height = origHeight/2;
Console.SetWindowSize(width, height);
Console.WriteLine(Console.WindowWidth);
Console.WriteLine(Console.WindowHeight);
Console.ReadKey(true);
Console.SetWindowSize(origWidth, origHeight);
Console.WriteLine(Console.WindowWidth);
Console.WriteLine(Console.WindowHeight);
}
}