August 30, 2005

Format of an c# Indexer

Indexer format:

class XXX 
{
// RETURN_TYPE is type that is returned by the indexer
// INDEX_TYPE is the indexer look up type
public RETURN_TYPE this[INDEX_TYPE index] 
{
  get{return ...;}
  set{... = value;}
}
Note that their can be multiple indexers
public RETURN_TYPE this[INDEX_TYPE_1 index1, ..., INDEX_TYPE_N indexN] 
{
  get{ ... }
  set{ ... }
}

No comments: