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
Is null c# operator?
What is the benefit of interface in c#?
Can abstract class have constructor c#?
Why does my windows application pop up a console window every time I run it?
What is the difference between disposing of () and finalize() methods in c#?
What is the difference between “out” and “ref” parameters in c#?
Can we override static class in c#?
If you want to write your own dot net language, what steps you will u take care?
Why do we need interface in c#?
What is uint64?
What is delegates in c#?
What are the return types in c#?
write program in c# using this instructions name avinash varma ,work experiance<2,nochildren his work experiance is higher than 5 years,more than one children one children name is diwakar,number of years of work eperiance at current company is the ratio of children and work experiance is 0.21 to 0.5
Does c# have primitives?
What is fcl in c#?