Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A type declaration is implicitly a static member

Tags:

c#

Someone I know just asked me to explain this statement from the MSDN and I was dumbfounded.

A constant or type declaration is implicitly a static member.

That phrase "or type declaration is implicitly a static member," just doesn't make sense to me.

What does that mean?

like image 288
Water Cooler v2 Avatar asked Sep 17 '13 05:09

Water Cooler v2


1 Answers

It makes sense to me that a type declaration is implicitly a static member.
Because if you have class:

class Foo
{
   public class Bar
  {
  }
}

You cannot access the class Bar by:

Foo f = new Foo();
Bar b =new f.Bar();

(I am not even sure how to write it in order for it to make sense).
If you want to access Bar class, you will need to do as follows:

Bar b = new Foo.Bar()

You access it via the class rather than an instance. of an object
Hence, Bar is a static member of Foo.

like image 157
Avi Turner Avatar answered Sep 20 '22 16:09

Avi Turner