C Program
-Collection of Members void main() <- entry point { -Call the members from here for execution }
In a Object Oriented Programming Language the Code is enclosed under a Container known as Class
CPP Program class Example { Collection of Members }; void main() <- entry point { -Create the object of class -Using the object invoke members of class }
-A Class is a User-defined Data type -To use it first create a copy of it
-Copy of a Class is known as object
-As per object oriented programming every line of code has to be under a Class only.
-In CPP Language the Main Function is defined out of the Class.
-Because anything under a Class has to be accessed only using the object of the Class, which gets created under the Main Function only.
-When Java Language was introduced it was designed in such a way that not even a single line of code can be present out of the Class. -To overcome the problem with Main it has introduced a concept known as Static.
-If a method is defined as Static object of the Class is not required to invoke it. -Main Method in Java Class will be defined as Static from where the execution starts.
Java Program class Example { Collection of Members static void Main() <- entry point { -Create the object of class -Using the object invoke members of class } }
C# was designed basing on the principals of Java so in case of Main it followed the guidelines laid by Java so it also defines Main as Static
C#.Net Program class Example { Collection of Members static void Main() <- entry point { -Create the object of class -Using the object invoke members of class } }