May 2010
Intermediate to advanced
1272 pages
61h 18m
English
Shared fields are useful to store information that is common to all instances of a class. For example, imagine you have a class named Document and that represents a text document. You could implement a shared field acting as a counter of all the documents opened in your application:

The code in the example increments the counter each time a new instance is created. The documentCounter field is common to all instances of the Document class because it is marked with the Shared keyword.
Read now
Unlock full access