ReadLine Function & Place Holder

C#This tutorial will demonstrate the use of ReadLine Function, which resides in Console class.  This function will help you in reading any string, which you will type in the console window.   The sample code for the ReadLine function is given below.

using System;

public class Program
{
public static void Main()
{
string FirstName;
string LastName;

Console.WriteLine("First Name");
FirstName = Console.ReadLine();

Console.WriteLine("Last Name");
LastName = Console.ReadLine();

Console.WriteLine ("Hello, {0} {1}", FirstName, LastName);
}
}

In the above code, with the help of WriteLine function, we will ask the user his first name as well as last name.   Both the names will be stored in 2 string variables, FirstName and LastName respectively.   To join both the names and display on the screen, we will make use of place holder.  The place holder is basically represented by two curly braces and one numerical value in between them.   In the above code, {0} will hold the value of FirstName and {1} will hold the value of LastName.