Read user input
Last updated:
8/21/2020
⁃
Difficulty:
Easy
Write a C# program that asks the user What is your favorite animal?. Then stop program execution using the Console.Read
statement. When the user presses Enter the program will respond Mine too! on the second line.
Input
Output
What is your favorite color?
Mine too!
Solution
using System;
public class ReadingUserInput
{
public static void Main(string[] args)
{
Console.Write("What is your favorite color? ");
Console.ReadLine();
Console.WriteLine("Mine too!");
}
}