Why the Main() method is static?

 Posted by Ddd on 2/9/2011 | Category: C# Interview questions | Views: 4341 | Points: 40

. The Main() method serves as the entry point of the code.It is automatically loaded and initialised by the CLR when the class loader in the CLR loads the class.If it were not static, an extra object of the class has to be created, that would increase the memory overhead.

. The other reason for being static is to prevent its overriding and not allowing it to be accessed through an object reference of derived class.

. Static will also have compile time memory allocation.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response