class method verses static method: whats the difference?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Taylor

    #1

    class method verses static method: whats the difference?

    "Static" is synonymous with "class" with regards to members (methods and
    fields) right? Sometimes I hear refrence to the "static method" and
    sometimes its refered to a "static method."

    Is there a subtle/grand difference between the two?

    For example here
    http://msdn.microsoft.com/library/de...verpattern.asp I
    read

    "A delegate instance holds a reference to an instance or class method,
    permitting anonymous invocation of the bound method."

    Then later:

    "During the creation of this delegate instance, the observer passes the name
    of the method (instance or static) that will be notified by the subject to
    the delegate."

    Is there a reason the authors chose to mention "static" in one place, then
    "class" in the the other?


  • Frank Oquendo

    #2
    Re: class method verses static method: whats the difference?

    Taylor wrote:[color=blue]
    > "Static" is synonymous with "class" with regards to members (methods
    > and fields) right?[/color]

    public class MyClass
    {
    public static readonly string SomeString = "Hello world!";

    public void SayHello()
    {
    Console.WriteLi ne(MyClass.Some String);
    }
    }

    The SayHello method is available only in an instance of MyClass while
    the field SomeString can only be accessed via the MyClass definition
    itself, even from within an instance of MyClass.

    --
    There are 10 kinds of people. Those who understand binary and those who
    don't.


    (Pull the pin to reply)


    Comment

    Working...