Can overrride the Main method
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / hellobapi
Base on the question,we can not override the main method in
a same class.
but in same namespace and in different classes we can use
many main methid. but at compile time their should be
specify.
| Is This Answer Correct ? | 11 Yes | 6 No |
Answer / swadesh kumar
we can not override main metod but use multiple main metod
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / guest
no we can t override main method ,but we use as multiple
times main method
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mukul
we can use multiple Main method within the same class and within the same namespace, but we can't override Main bcoz Main() is static.
| Is This Answer Correct ? | 0 Yes | 0 No |
Which is faster dictionary or hashtable?
What is the difference between a field and a property in c#?
List some of the common data providers for ado.net framework?
How do I create a single-file assembly?
How to navigate from one page(form) to another page(form) using C#.net...please give me the example
What is strongly typed in c#?
What is a partial method?
how can we pass parameters to a user control using delegates ?
Does c# support const methods, properties, or events?
Are there functions in c#?
Explain the access modifiers in c#?
What is event delegate in c#?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)