Implementing an indexer for your object with C# .NET
December 8, 2016 Leave a comment
Indexers are used extensively when accessing items in an array or List:
Friend f = friends[2];
It’s fairly easy to implement your own indexer. Imagine a table with guests sitting around. We could implement an indexer to easily access guest #n.
The Guest object is simple with only one property:
public class Guest
{
public string Name { get; set; }
}