Read user input from command line and change the console color : Command Line « Development « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

  class Program
  {
    static void Main(string[] args)
    {
      Console.Write("Please enter your name: ");
      string userName = Console.ReadLine();
      Console.Write("Please enter your age: ");
      string userAge = Console.ReadLine();

      ConsoleColor prevColor = Console.ForegroundColor;
      Console.ForegroundColor = ConsoleColor.Yellow;

      Console.WriteLine("Hello {0}!  You are {1} years old.",userName, userAge);

      Console.ForegroundColor = prevColor;
    }
  }








14.10.Command Line
14.10.1.Display all command-line information
14.10.2.See if arguments are present
14.10.3.Iterate over command-line arguments and print them out
14.10.4.Read user input from command line and change the console color