To read inputs as strings in C#, use the Console.ReadLine() method.
str = Console.ReadLine();
The above will read input as string. You don’t need to use the Convert method here since the input takes string by default.
Now display the string entered by user −
Example
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
string myStr;
// use ReadLine() to read the entered line
myStr = Console.ReadLine();
// display the line
Console.WriteLine("Result = {0}", myStr);
}
}Output
Result =
The following is the output. Let’s say the user entered “Amit” as the input −
Result = amit