Shared Members
Classes can expose instance and shared members. Until now, all discussions used instance members for examples. It’s important to understand what the difference between instance and shared members is, because you can successfully use both of them in your classes. Basically, when you create a new instance of a class, you create a copy of that class with its own life and its own data. On the other hand, with shared member you work with only one copy of a class and of its data. Classes can support different situations, such as all shared members or just a few shared members. For example, if you have a class exposing only shared members, you work with exactly one copy of the class. If you have only a few shared members within a class, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access