CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Apr 2011
    Posts
    58

    Just when I thought I fully understood static vs non-static methods...

    I was looking through a program I am working on, and my Form1 class has several methods that are NOT static, but I call them like they are static.

    Code:
    public partial class Form1 : Form
    {
      public Form1()
      {
        //constructor
        DoSomething();
      }
    
      private void DoSomething()
      {
      }
    }
    since DoSomething is not static, I thought it would need an object reference, such as this.DoSomething()???

    But this does compile and run, so I am confused.

    What did I miss when I was studying static methods?

    Skip
    Last edited by MrGibbage; August 10th, 2011 at 09:48 AM.

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

Featured