Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of "this [int index]"?

Tags:

c#

.net

interface

In C# we have the following interface:

public interface IList<T> : ICollection<T>, IEnumerable<T>, IEnumerable
{
    T this [int index] { get; set; }
    int IndexOf (T item);
    void Insert (int index, T item);
    void RemoveAt (int index);
}

I don't understand the line

T this [int index] { get; set; }

What does it mean?

like image 748
boris Avatar asked May 28 '15 15:05

boris


1 Answers

That is an indexer. So you can access the instance like an array;

See MSDN documentation.

like image 63
tbddeveloper Avatar answered Nov 01 '22 09:11

tbddeveloper