I was wondering whether it was possible to also use indexers for single objects. So,
class A<T>
{
public T this[int index]
{
//get, set using index
}
private T _t;
}
I was wondering whether the following was possible? (or something that looks like it)
class A<T>
{
public T this
{
//no indexer? essentially get { return _t; } set ...
}
private T _t;
}
Thanks!
1
You can use implicit conversion operators to do this sort of thing where one type acts like another type.
The only limitation is that you can only have a getter or a setter, not both for a given other type.
0