2

Possible Duplicate:
Why it is not posible to define generic indexers in .NET?
how to write a function to take any object with an index operator

I've never seen any usage like that. But I just wonder if it is possible to make an implementation like bleow. I know that it's not working. But I mean a similar usage if exist.

public T this<T>[T param]
{
    get 
    {
        ....
    }
}
Community
  • 1
  • 1
Halil Ibrahim
  • 1,339
  • 1
  • 20
  • 39
  • 1
    A quick search would answer your question: http://stackoverflow.com/questions/494827 or http://stackoverflow.com/questions/7043028/ – Brian Kintz Feb 04 '13 at 08:34
  • It is possible using an interface `public interface IIndexable { T this[I index] { get; set; } }` and adding this to your method/class `where T : class, IEnumerableExtensions.IIndexable` – DerpyNerd Nov 18 '16 at 08:01

1 Answers1

4

No, generic properties, and indexers (a property), aren't possible.

Grant Thomas
  • 44,454
  • 10
  • 85
  • 129