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
What is event sourcing in c#?
What is the use of functional interface?
How long can a string be c#?
What is the difference between method and constructor in c#?
Explain the difference between abstract class and interface in .net?
What is base class in c#?
Why delegates are required?
What is parsing? How to parse a date time string?
Define encapsulation?
What is singleordefault c#?
Why do we need escape characters?
Define Final Class in C#
Explain the difference between the debug class and trace class?
What is use of console?
I need code to connect ohter systems in the LAN and i want to display my website image over there and i want explain as a admin through phone. So i need code to access other system using C-Sharp. Any one please help me.Please give me the code. Advace thanks.