Is it possible to have something like the following:
class C { public Foo Foos[int i] { ... } public Bar Bars[int i] { ... } }
If not, then are what are some of the ways I can achieve this? I know I could make functions called getFoo(int i) and getBar(int i) but I was hoping to do this with properties.
Not in C#, no.
However, you can always return collections from properties, as follows:
IList<T> has an indexer, so you can write the following:
On the lines ‘return …;’ you can return whatever implements IList<T>, but you might what to return a read-only wrapper around your collection, see AsReadOnly() method.