Every time I try to explain shared (static) members I end up in a discussion over global variables. Usually the discussion goes like this : “Hey I just heard there are no global variables in .NET and now I don't see the differnece between MyGlobalvar and MyCalss.GlobalVar”.
I have several answers :
- A shared member has identity. It is member of typeX.
The shared members does not exist without the type is a member of
- Public types are “global” to your application. And also to any code referencing the class.
- Not every type is public
- Not every shared member is public
These don't convince everybody. Does anybody know of a simpler way of explaining the difference ?
Peter
Posted
Mon, Oct 18 2004 3:01 PM
by
pvanooijen