How to change the WindowHeight of the Console in C#?


Use the Console.WindowHeight Property to change the WindowHeight of the Console.

Example

Let us now see an example −

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Demo {
   public static void Main (string[] args) {
      Console.InputEncoding = Encoding.ASCII;
      Console.WriteLine("Input Encoding Scheme = "+Console.InputEncoding);
      Console.OutputEncoding = Encoding.ASCII;
      Console.WriteLine("Output Encoding Scheme = "+Console.OutputEncoding);
      Console.CursorVisible = false;
      Console.Write("
Cursor is Visible? "+ Console.CursorVisible);       Console.WindowHeight = 30;       Console.Write("WindowHeight = "+Console.WindowHeight);    } }

Output

This will produce the following output −

Input Encoding Scheme = System.Text.ASCIIEncoding
Output Encoding Scheme = System.Text.ASCIIEncoding
Cursor is Visible? False
WindowHeight = 30

Updated on: 14-Nov-2019

90 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements