Why we put main method as static only? [Resolved]

Posted by Rajeshk under Others on 12/29/2012 | Points: 10 | Views : 876 | Status : [Member] | Replies : 3
hi all,
can anybody tell me Why we put main method as static only? is it compulsory what is the use of it ? replay needed

Thanks&Regards
rajeshkommireddy@gmail.com



Responses

Posted by: Shubham on: 12/29/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Good Question bro!!!!!!
here is explanation
When a program is launched, no instances of any class are present in memory. As the Main method is static, it can be called without creating an object and can then assume control of the program. It is the Main method's task to create the objects that the program requires to function correctly.
A class can be declared static, indicating that it contains only static members. It is not possible to create instances of a static class using the new keyword. Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded
that is why always we make main method as static
if you dont make main method as static so main method not calling on load event......

Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandeepmhatre on: 12/29/2012 [Member] Starter | Points: 25

Up
0
Down
Refer this link

http://sandeepmhatre.blogspot.com/2012/12/static-members.html

Sandeep M,
Software Developer
Follow me on :
http://sandeepmhatre.blogspot.in

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajeshk on: 12/31/2012 [Member] Starter | Points: 25

Up
0
Down
Thank you subham your answer had cleared my doubt:)

Thanks&Regards
rajeshkommireddy@gmail.com

Rajeshk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response