Identifying a custom indexer using reflection in C#

You can also look for index parameters, using the the PropertyInfo.GetIndexParameters method, if it returns more than 0 items, it’s an indexed property:

foreach (PropertyInfo pi in typeof(MyClass).GetProperties())
{
    if (pi.GetIndexParameters().Length > 0)
    {
       // Indexed property...
    }
}

Leave a Comment