class method verses static method: whats the difference?

  • Thread starter Thread starter Taylor
  • Start date Start date
T

Taylor

"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/default.asp?url=/library/en-us/dnbda/html/observerpattern.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?
 
Taylor said:
"Static" is synonymous with "class" with regards to members (methods
and fields) right?

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

public void SayHello()
{
Console.WriteLine(MyClass.SomeString);
}
}

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.

http://code.acadx.com
(Pull the pin to reply)
 
Back
Top