1
Reply

Can i have more than Main() function in c#. Give the explanation

Munesh  Sharma

Munesh Sharma

13y
5.8k
0
Reply

    Yes,We can have more than one Main function in C# program.............

    Just take an Example

    using System;
    class A
    {
    public static void Main()
    {
          Console.WriteLine("Class A");
    }
    }
    class B
    {
    public static void Main()
    {
          Console.WriteLine("Class B");
    }
    }
    class C
    {
    public static void Main()
    {
          Console.WriteLine("Class C");
    }
    }

    save this as file.cs.
    and in the cmd run this file
    as 
    command:--
    csc file.cs /main:classname 
    className is the name of the class which you want to compile now...


    I hope you get ur answer .if you are not satisfied rep soon..............and post your comments.