Common Type System—Indexer Properties
Indexer Properties
A special variant on properties called an indexer property may be supplied. Consider this example:
class Customer { private Dictionary<int, Order> orders; public Order this[int id] { get { return orders[id]; } set { orders[id] = value; } } }
This is essentially a default property for a type, indicated by the System.Reflection.DefaultMemberAttribute in the IL. This style of property enables callers to access your object using special syntax. For
example, C# permits callers to use an array-like syntax for this:
Customer c = /*...*/; Order o = c[10010];
Indexer properties are also special in that they can be overloaded through the parameters. You may also use multiple parameters for input.
|

