Search code examples
c#visual-studio

Show custom indexer in debugger


I have sample indexer like ths:

public byte this[long pIndex]
{
    get
    {
        // return something
    }
}

How to tell Visual Studio to display all elements from this indexer in debugger? And how to tell about pIndex range?


Solution

  • You can implement IEnumerable interface in your class. Debugger can use it to get all the items and display them the same way it displays linq expression results.

    If you want to see the single element, you can add a watch expression this[123]