Read line from console window - CSharp Language Basics

CSharp examples for Language Basics:Console

Description

Read line from console window

Demo Code

using System;//from  w  w  w.ja  va2 s . com
class Program
{
    static void Main(string[] args)
    {
        Console.Write("Type your first name and press ENTER: ");
        string firstName = Console.ReadLine();
        Console.Write("Type your age and press ENTER: ");
        string age = Console.ReadLine();
        Console.WriteLine($"Hello {firstName}, you look good for {age}.");
    }
}

Result


Related Tutorials