You will get some input from user in the console window.
Accepts a single line of text from the user and immediately repeats the inputted text to the output.
When you launch the program using the F5 key from Visual Studio, you will see an empty screen.
Enter a sentence and send it to the program using the Enter key.
using System; using System.Globalization; class Program/*ww w . j ava 2 s . com*/ { static void Main(string[] args) { // Reading single line of text (until user presses Enter key) string input = Console.ReadLine(); // Outputting the input Console.WriteLine(input); } }
Modify the previous program to give the user a hint about what she is supposed to do.
using System; using System.Globalization; class Program// www .j a v a 2 s .c om { 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); } }
Console.Write does not transfer the cursor to the next line.
Console.WriteLine adds new line and moves the cursor to the next line.