Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can overrride the Main method

Answer Posted / shashi bhushan vishwakarma(tus

we can not override the Main method but we can use multiple
Main method within the same class also and within the same
namespace also.
ex.
namespace ConsoleApplication1
{
class Program
{
public void Main()
{
Console.WriteLine("hello");
}
public static void Main(string[] args)
{
Console.WriteLine("hello c# 2010");

Program o = new Program();
o.Main();
Console.ReadLine();

}
}
}

Output:
hello c# 2010
hello

another Ex.

namespace ConsoleApplication1
{
class Program
{

public static void Main(string[] args)
{
Console.WriteLine("hello c# 2010");

a obj = new a();
obj.Main();
Console.ReadLine();

}
}


class a:Program
{
public void Main()
{
Console.WriteLine("hello");
}

}
}

output:
hello c# 2010
hello

Is This Answer Correct ?    17 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you put two constructor with the same structure in a class?

866


Explain About Postback

890


What is the difference between string keyword and system.string class?

1029


What is a property in c#?

855


Illustrate race condition?

843


What is a interface in c#?

922


Which compiler switch creates an xml file from xml comments in the files in an assembly?

950


What is variable and its classification?

893


Is cli same as the clr?

846


Give an example to show for hiding base class methods?

807


What are "class access modifiers" in C#?

898


What is different between Implicit conversion and Explicit conversion in C#?

969


Can constructor have return type c#?

972


What are object pooling and connection pooling and difference between them?

943


What are delegate methods?

899