using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFirstProgram
{
class Program
{
static void Main(string[] args)
{
}
}
}
And another class in another file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rock_Paper_Scissors
{
internal class ComputerGenerateSign
{
public string computer;
Console.ReadKey()
}
}
Why Visual Studio code have a problem ?>"Error IDE1007 The name ‘Console.ReadKey’ does not exist in the current context"
2
Answers
Use ‘Console.ReadKey();’ in the body of a method, That way it will recognize. You didn’t write a method inside the ‘ComputerGenerateSign’ class like the class ‘program’ has the main method. hope this helps.
You have made function call in class which was not allowed. In class you can define properties, fields and functions.
You need to call that function inside a function body.
Main.cs
And another class in another file