Reading single line of text (until user presses Enter key) - CSharp Language Basics

CSharp examples for Language Basics:Console

Description

Reading single line of text (until user presses Enter key)

Demo Code

using System;// w w  w  .j a va2 s  .  co m
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
   static void Main(string[] args)
   {
      // Hinting user what we want from her
      Console.Write("Enter a sentence (and press Enter): ");
      // Reading line of text
      string input = Console.ReadLine();
      // Repeating to the output
      Console.WriteLine("You have entered: " + input);
   }
}

Result


Related Tutorials