Console.ReadLine method in C#
In this article, I will explain you about Console.ReadLine method in C#.
Introduction
A console application is the simplest form of C# program. Console programs are very easy to develop. Console programs read input and write output. For reading purpose we can use Console.ReadLine method. Console.ReadLine method reads a line of text from the console window, when we press enter it returns a string.
Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
// Write to console window.
string s;
Console.WriteLine("----------------Enter your name---------------");
s = Console.ReadLine();
Console.WriteLine("My name is:{0}" ,s);
Console.ReadLine();
}
}
}
The output of following program
