Manipulate the Appearance of the Console - CSharp Language Basics

CSharp examples for Language Basics:Console

Description

Manipulate the Appearance of the Console

Demo Code

using System;//w  w w  .  j a v a2 s  .co m
class MainClass
{
   static void Main(string[] args)
   {
      // Display the standard Console.
      Console.Title = "Standard Console";
      Console.WriteLine("Press Enter to change the Console's appearance.");
      Console.ReadLine();
      // Change the Console appearance and redisplay.
      Console.Title = "Colored Text";
      Console.ForegroundColor = ConsoleColor.Red;
      Console.BackgroundColor = ConsoleColor.Green;
      Console.WriteLine("Press Enter to change the Console's appearance.");
      Console.ReadLine();
      // Change the Console appearance and redisplay.
      Console.Title = "Resized Console";
      Console.ResetColor();
      Console.Clear();
      Console.SetWindowSize(100, 50);
      Console.BufferHeight = 500;
      Console.BufferWidth = 100;
      Console.CursorLeft = 20;
      Console.CursorSize = 50;
      Console.CursorTop = 20;
      Console.CursorVisible = false;
   }
}

Result


Related Tutorials