Search code examples
c#entry-point

Can I determine my own entry point method for C#


I wrote a program which has two main method.And I specified entry point with Command Prompt.

class Program
{
    static void Main()
    {
        Console.WriteLine("Test");
    }
}
class Test
{
    static void Main()
    {
        Console.WriteLine("Test");
    }
}

csc Program.cs /main:Test

Well.Can I determine entry point method with command prompt?

for example

class Program
{
    static void NewEntry()
    {
        Console.WriteLine("Test");
    }
}

Then

csc Program.cs entry/Program::NewEntry()

Is this possible?


Solution

  • No. The static Main() is the only entry point for C#, and all other functions should be called from it.