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
Difference between directcast and ctype.
is it possible to access a remote web service Without UDDI?
What are the fundamental principles of oo programming?
Does unity use c++ or c#?
What is delegates and events?
What is the difference between int16 and int32 in c#?
Is string nullable c#?
Which debugging tools you can use in the .NET ssSDK?
What is predicate builder?
Explain clr in brief.
What are the differences between a class and a struct?
Give an example of a ctype.
Can we have multiple constructors in a class c#?
What is the difference between final finally and finalize in c#?
What is nameof c#?