Can overrride the Main method

Answers were Sorted based on User's Feedback



Can overrride the Main method..

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

Can overrride the Main method..

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

Can overrride the Main method..

Answer / radix

No u cant

Is This Answer Correct ?    5 Yes 2 No

Can overrride the Main method..

Answer / swadesh kumar

we can not override main metod but use multiple main metod

Is This Answer Correct ?    1 Yes 1 No

Can overrride the Main method..

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

Can overrride the Main method..

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

Post New Answer

More C Sharp Interview Questions

What is parameters in c#?

0 Answers  


What is the use of tryparse in c#?

0 Answers  


Can you allow class to be inherited, but prevent the method from being over-ridden?

2 Answers   Mind Tree,


wipro interview question on 28-Apr-10 1.what type of authentication used in web service, 2.what are type of multithreding ? 3.diff bet delegate and multithreading? 4.how to write update query trigger in stored procedure. 5. if you are so sharp then what happens when you click .net appln exe in system,who CLR get loaded. 6.how to use work flown in application. 7.what is main purpose of script manager. 8.how u handle cretical transaction. 9.how you syncronize the method from no of user, 10.how change name of shared assambly

1 Answers  


What is the size of a decimal?

0 Answers  






Explain the process of polymorphism with an example?

0 Answers  


Are value types sealed?

0 Answers  


What is dictionary collection in c#?

0 Answers  


How can you reference current thread of the method ?

0 Answers  


What is a delegate?

5 Answers   Siebel Systems,


Why would you use untrusted verificaion?

1 Answers  


What is virtual in c#?

0 Answers  


Categories