As I had never written a console application, I thought it was a good idea to start now. If only because of the fact that I find Visual Studio rather sluggish and the idea to be able to test code quickly on one of the playgrounds such as dotnetfiddle seems attractive. The default compiler on dotnetfiddle.net is on .NET 4.7.2 but I noticed that that one choked on the more recent code I borrowed. So I got used to the fact that I have to switch the compiler to .NET 5 to be able to take advantage of for instance niceties such as the $ to format text.
TL;DR
However, I found that a simple ReadLine()
such as found in the example on https://dotnetfiddle.net/tAJulh doesn't work if you change the compiler to .NET 5. Has something changed in the specification of ReadLine in .NET 5 or is this a limitation of dotnetfiddle? And is there a way around this?
using System;
public class Program
{
public static void Main()
{
// Simply writes the following text to the standard output
Console.WriteLine("Input some text!");
// Reads text until you hit "enter"; and saves it to the "input"-variable
var input = Console.ReadLine();
// Writes the "input"-variable to the console.
Console.WriteLine("Your input was: " + input);
// The program will not exit until you hit "Enter".
Console.ReadLine();
}
}
You are absolutely right. Does look like an error on dotnetfiddle and you should report it here: https://dotnetfiddle.uservoice.com/forums/228764--net-fiddle-ideas
As far as i can tell, there is no way around it before they correct the bug.
As some other guys have stated i highly recommend that you get an IDE, this could be visual studio code or the plain visual studio
Personally i enjoy VS code for it's simplicity and it works great for C# and .net