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 int a class in c#?
What is the use of GC.KeepAlive Method?
what is IDisposal interface,IComparable,IEquatable,IFormatable
What is var c#?
Can we inherit abstract class in c#?
What is the base class of all classes in c#?
How Do You Convert A Value-type To A Reference-type?
What is the difference between dll and lib?
What is the data provider name to connect to access database?
How do you create partial methods?
Can the accessibility of a type member be greater than the accessibility of its containing type?
What is the difference between “constant” and “readonly” variables in c#?
What is use of list in c#?
What is xor operator in c#?
Is multiple inheritance possible in c#?