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 public, private, protected, internal and internal protected?
What is virtual in c#?
What is multicast delegate in c# ?
Is learning c# hard?
List down the different ide’s provided by microsoft for c# development.
Define a partial class?
What is file extension of webservices?
Explain About delegates
What is a method signature in c#?
What is application object in c#?
Are c# strings immutable?
what is the difference between .dll and .exe
What is the difference between array and arraylist c#?
What is datetime minvalue in c#?
Is c sharp and c# are same?