I need help using input in c# workspace

Hi, sorry to bother anyone but I am needing help using inputs in the c# workspace!
Does anyone know what to do?
Here is my code:
using System;

namespace SandboxProject
{
class Program
{
static void Main()
{
Console.WriteLine("Enter your name: ");

Console.ReadLine();
}
}
}
Thanks!

Check this documentation out. It may be that your ‘Console.ReadLine();’ needs to be assigned to a value like the documentation shows.

Main resource - C# Input

Additional resource - Difference between ReadLine(), Read() and ReadKey() method:

1 Like

I did that and tried a new workspace, however, there is no option in the console itself to input anything!
any suggestions?

using System;

namespace sandbox
{
class MyClass
{
public static void Main(string args)
{
string userInput;
Console.WriteLine(“Please enter a word!”);
userInput = Console.ReadLine();
Console.WriteLine(userInput);
}
}
}

using System;

// WORKING CODE... 2 ERRORS FOUND IN THE ORGINAL CODE...
// 1. YOUR QUOTATIONS MARKS ARE THE PROBLEM. 
//     THEY ARE OF TWO DIFFERENT TYPES.
//     “ ” does not equal " " 

// 2. YOU DID NOT SET (string[] args) ... YOU ONLY (string args)
namespace sandbox
{
    class MyClass
    {
         public static void Main(string[] args)
        {
            string userInput;
            Console.WriteLine("Please enter a word!");
            userInput = Console.ReadLine();
            Console.WriteLine(userInput);
        }
    }
}


// YOUR ORIGINAL CODE
// namespace sandbox
// {
//     class MyClass
//     {
//          public static void Main(string args)
//         {
//             string userInput;
//             Console.WriteLine(“Please enter a word!”);
//             userInput = Console.ReadLine();
//             Console.WriteLine(userInput);
//         }
//     }
// }

// EXAMPLE USED TO DEBUG ORIGINAL CODE
// namespace Sample
// {
// 	class Test
// 	{
// 		public static void Main(string[] args)
// 		{
// 			string testString;
// 			Console.Write("Enter a string - ");
// 			testString = Console.ReadLine();
// 			Console.WriteLine("You entered '{0}'", testString);
// 		}
// 	}
// }

Hey!

Unfortunately yes, that is correct. Some of the Codecademy workspaces and lessons just aren’t built to be able to take in user input (the ones that are often have a “bash” style terminal instead). Unfortunately you’ll have to either work locally on an IDE like Visual Studio, or use another online platform such as Replit.

Happy coding!

1 Like

Thank you for the help!

1 Like