C# Console WindowHeight

Description

Console WindowHeight gets or sets the height of the console window area.

Syntax

Console.WindowHeight has the following syntax.


public static int WindowHeight { get; set; }

Example


using System;/*from ww w.  ja  v  a2s.  co 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);

    }
}




















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version