Console.WriteLine("Enter arguments");
string input = Console.ReadLine();// red line under Console.ReadLine
Console.WriteLine("Arguments at run-time  " + input);

/* I want to show the user input in string through my Console.WriteLine method and I know by-default it is in string type so why am getting red line under Console.ReadLine when using string and not when store in var type? Thanks! */

1

There are 1 best solutions below

1
On BEST ANSWER

The Console.ReadLine(); function can return a null value and the IDE indicates that for safety. Use string?.