top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

In C#/.net Main() method is private then how compiler access this Main() Method out side the class?

+3 votes
429 views

By-default all the methods & variables in class are private.

In C#.net Main() method is private then how compiler access this Main() Method out side the class because compiler is not part of our program then how compiler access this Main() method?

Here we loose our data abstraction property ? Can anyone put some light on it?

posted Sep 17, 2014 by Dilbagh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Static members are scoped to the class level (rather than the object level) and can thus be invoked without the need to first create a new class instance. A main method is static because it is available to run when your program starts and as it is the entry point of the program it runs without creating an instance of the class.

In other words, static functions exist before a class is instantiated so static is applied to the main entry point (Main method).

answer Dec 18, 2015 by anonymous
Similar Questions
+1 vote

All constructors are public then why not destructor? If it is private then how compiler access these private destructor?

+4 votes

Is it possible to override this method? if yes then how can we achieve it?

...