CSharp - Overload the Main() method

Introduction

Consider the following program.

Demo

using System;

class Program//from   www.  j a  va  2  s . co m
{
    static void Main(string[] args)
    {
        Console.WriteLine("I am inside Main(string[] args) now");
        Console.WriteLine("Calling overloaded version\n");
        Main(5);
    }
    static void Main(int a)
    {
        Console.WriteLine("I am inside Main(int a) now");
    }
}

Result

Analysis

Although you can compile and run the preceding program, the compiler will show you warning message.

Related Topic