Answer the question
In order to leave comments, you need to log in
The contents of the method are not displayed. What to do?
I recently noticed that text is not displayed inside the method.
The code is here:
using System;
namespace Application
{
class Program
{
static void Main(string[] args)
{
void Method()
{
Console.WriteLine("Hello world");
}
}
}
}
Hello world
. using System;
namespace Application
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello world");
}
}
}
Answer the question
In order to leave comments, you need to log in
In the first case, you only declared a local method. If it is not called, then the code from it will not be executed.
If you want the code from the first option to work - write
using System;
namespace Application
{
class Program
{
static void Main() // Обявили статичный метод Main
{
void Method() // Объявили локальный метод внутри Main
{
Console.WriteLine("Test");
}
Method(); // Вызвали метод
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question