Monday, 13 December 2010

Abstract Properties and Indexers

Example
abstractclass Sequence
{
 public abstractvoid Add(object x);                // method
 public abstractstring Name { get;}                // property
 public abstractobject this [int i] { get; set;}  // indexer
}
class List : Sequence
{
 public overridevoid Add(object x) {...}
 public overridestring Name { get {...}}
 public overrideobject this [int i] { get {...} set {...}}
}
Note�Overridden indexers and properties must have the same get and set methods as in the base class

No comments:

Post a Comment