C
C
CityzenUNDEAD2020-08-05 18:02:01
C++ / C#
CityzenUNDEAD, 2020-08-05 18:02:01

Why can't you use Console inside your class?

Hello everyone!
Why can't you use the Console inside your class?

class Test 
    {
        Console.WriteLine("text");
    }

ide writes that the console does not exist in the current context.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Demidko, 2020-08-05
@CityzenUNDEAD

You are trying to call WriteLine in the wrong place. Immediately inside a class, only its fields or methods can be described. That is, first you need to create a method in your class

class Test 
{
  public void TestMethod()
  {
    Console.WriteLine("text");
  }
}

A
Alexander Ananiev, 2020-08-05
@SaNNy32

In the project settings, you need to set ConsoleApplication

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question