Results 1 to 2 of 2

Thread: difference between static void main() and void main()

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    43

    difference between static void main() and void main()

    Hello guys,

    Please someone explain me the above question please? with example would be great

    Cheers,
    Dummy
    Last edited by dummy_pmgr; Sep 20th, 2004 at 09:30 AM.
    ***learning everyday ***

  2. #2
    Member
    Join Date
    Sep 2004
    Location
    Oklahoma City, OK
    Posts
    36
    Using the static modifier on any member of a class means that the member belongs to the type itself instead of an instance of an object. Examples of static methods commonly used would be Console.WriteLine or MessageBox.Show. Neither of these methods requires an object to be instantiated before use.

    If you have the .NET Framework documentation local to your system, check the following link.

    http://ms-help://MS.NETFrameworkSDKv...rfStaticPG.htm

    The void modifier means that the method doesn't return a value of any kind.

    The Main method of an assembly is the entry point for that assembly, similar to a constructor in the sense that you can initialize whatever components and variables needed to operate the assembly. An example would be the following:

    Code:
    public class SomeWindowsForm : Form {
    	public static void Main() {
    		Application.Run(new SomeWindowsForm());
    	}
    
    	public SomeWindowsForm() : base() { ... }
    }
    Hope that's helpful.
    Thomas Corey
    IT Engineering Consultant
    TALSoft Enterprises Inc.
    Oklahoma City, OK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width