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 the difference between list and arraylist in c#?
What is windows forms in c#?
What is method and function in c#?
Explain boxing and unboxing in c#?
What is the .NET collection class that allows an element to be accessed using a unique key?
What is difference between events and delegates?
What is session and cookies in c#?
What is the c# equivalent of c++ catch (…), which was a catch-all statement for any possible exception? Does c# support try-catch-finally blocks?
When is a class declared as a class abstract?
What is difference between private and protected in c#?
What is assembly c#?
List some of the basic string operation?
what are the differences between a class and structure
what is the difference between convert.tostring() and tostring() functions ?
What is dependency in software?