November 2002
Intermediate to advanced
560 pages
11h 16m
English
The example in Listing B.3 implements a simple stack component in C#. It demonstrates the use of component-oriented features such as properties, indexers, and XML comments. A more complete example would also implement the ICollection and IList interfaces.
using System; /// <summary> /// A general-purpose stack class /// Not thread-safe /// </summary> class Stack { const int sizeIncrement = 10; private int count = 0; private object[] values = new object[sizeIncrement]; /// <summary> /// The number of elements in the stack /// </summary> public virtual int Count { get { return count; } } /// <summary> /// Remove the top element from the stack /// and return it /// </summary> /// <returns>The top element</returns> ... |
Read now
Unlock full access