I do not see any documentation for this, but it is like vNext, you can happily compile and run the application with a non-static method void Main(). In fact, the new console application template provides you with a non-static Main. For instance:
public class Program
{
public Guid MyGuid { get; set; } = Guid.NewGuid();
void Main()
{
Console.WriteLine("Hello World {0}", MyGuid);
Console.ReadLine();
}
}
MyGuidcreated and is a non-empty guid here. Therefore, I assume that it creates an instance of my program class and goes from there.
My question is that I have two Mains:
public class Program
{
void Main()
{
Console.WriteLine("main no args");
Console.ReadLine();
}
void Main(string[] args)
{
Console.WriteLine("main with args {0}", string.Join(", ",args));
Console.ReadLine();
}
}
In the project properties, I gave arguments arg1and arg2. However, my console displays main no argsat startup. If I remove the argument Main, I get the expected result main with args arg1, arg2.
, , Main . , Main , main with args.
, Main. ? , , .
Edit
- Program, , , . the first Main method in the Program class