Console.ReadLine method in C#

In this article, I will explain you about Console.ReadLine method in C#.
  • 7985


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.


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);





The output of following program


© 2020 DotNetHeaven. All rights reserved.