Why main method is static in c#?



Why main method is static in c#?..

Answer / Manoj Kumar Sharma

The main method is static because it needs to be called before any non-static member (or object) of a class, and the .NET runtime requires a default instance of the application domain to call the main method. By making it static, we ensure that only one instance exists, which simplifies the execution.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Can you have parameters for static constructors?

1 Answers  


What is Delegate and what is it used for ?

1 Answers   NA,


Can firstordefault return null?

1 Answers  


What are immutable types in c#?

1 Answers  


Why do I get a security exception when I try to run my c# app?

1 Answers  


Is c# a strongly-typed language?

1 Answers  


What is difference between a function and a method?

1 Answers  


What is the difference between and xml documentation tag?

1 Answers  


What is the use of console readkey in c#?

1 Answers  


What are the types of threading models ?

4 Answers   Digital GlobalSoft,


Name some string escape sequences in c#.

1 Answers  


What is the Use Of Interfaces? For example I have a interface as shown below? Interface IMyInterface { public void MyMethod(); } class MyClass : IMyInterface { public void Mymethod() { Some Code } } class Program { static void Main(string[] args) { MyClass obj = new MyClass(); obj.MyMethod(); } } Here What is My Question is? If i remove Interface and run this code, it will executed then what is the Use of the interface? Can any one give me the solution for this Problem? Thanks in Advance!

1 Answers   HCL,


Categories