.NET fiddle not letting me write in console

1.4k Views Asked by At

NOTE: I have figured out that this only affects .NET fiddle if you are using .NET 6. If you aren't using .NET 6 it works fine.

Whenever I use the Console.WriteLine() function on .NET fiddle, it doesn't let me interact with the console. I'm new at coding and .NET fiddle, so it might be a simple fix. I just hope you can figure it out

I've tried just having the Console.WriteLine. I've triple checked I wrote it right. I rewrote the Convert.ToInt32 several times. I looked up to see if anyone else had this problem. I even checked if Console.WriteLine being under the list maker was the problem, it wasn't.

Here is the code:

using System;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        
        List<string> shoppingList = new List<string>();
        
        Console.WriteLine("How many items on the list?");
        
        int listLength = Convert.ToInt32( Console.ReadLine() );
            
        for(var i = 0; i < 4; i++) {
            shoppingList.Add(Console.ReadLine());
        }
        
        for(var i = 0; i < shoppingList.Count; i++) {
            Console.WriteLine(shoppingList[i]);
        }
    }
}
1

There are 1 best solutions below

0
On

It's working fine here on my side, as you can see here. Have you tried cleaning the cookies of your browser? Note that you have to click on the console to type. Also, I fixed your function where it gives the correct size of the List<string>.

using System;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        
        List<string> shoppingList = new List<string>();
        
        Console.WriteLine("How many items on the list?");
        
        int listLength = Convert.ToInt32( Console.ReadLine() );
            
        for(var i = 0; i < listLength; i++) {
            shoppingList.Add(Console.ReadLine());
        }
        
        for(var i = 0; i < shoppingList.Count; i++) {
            Console.WriteLine(shoppingList[i]);
        }
    }
}