X, F1, Z, Escape key from ConsoleKey

image_pdfimage_print

using System;
using System.Collections.Generic;

class MainClass
{
public static void Main()
{
ConsoleKeyInfo key;

List input = new List();

do{
key = Console.ReadKey(true);
if (key.Key == ConsoleKey.F1)
{
Console.WriteLine(“F1”);
}
if (key.Key == ConsoleKey.Backspace)
{
if (input.Count > 0)
{
input.RemoveAt(input.Count – 1);

Console.Write(key.KeyChar);
}
}else if (key.Key == ConsoleKey.Escape){
Console.Clear();
Console.WriteLine(“Input: {0}

“,new String(input.ToArray()));
input.Clear();
}else if (key.Key >= ConsoleKey.A && key.Key <= ConsoleKey.Z){ input.Add(key.KeyChar); Console.Write(key.KeyChar); } } while (key.Key != ConsoleKey.X || key.Modifiers != ConsoleModifiers.Alt); } } [/csharp]

CursorVisible ResetColor SetWindowSize BufferHeight BufferWidth CursorLeft CursorSize CursorTop

image_pdfimage_print
   
 

using System;

public class MainClass
{
    static void Main(string[] args) {
       // 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;
   }
}

    


CursorVisible ResetColor SetWindowSize BufferHeight BufferWidth CursorLeft CursorSize CursorTop

image_pdfimage_print
   
 

using System;

public class MainClass
{
    static void Main(string[] args) {
       // 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;
   }
}

    


Displaying the sum of two numbers input from the keyboard.

image_pdfimage_print
   


using System;

public class Addition
{
   public static void Main( string[] args )
   {
      int number1; 
      int number2; 
      int sum; 

      Console.Write( "Enter first integer: " ); 
      number1 = Convert.ToInt32( Console.ReadLine() );

      Console.Write( "Enter second integer: " );
      number2 = Convert.ToInt32( Console.ReadLine() );

      sum = number1 + number2;

      Console.WriteLine( "Sum is {0}", sum );
   } 
}