I'm using C# and ArcGIS for Desktop 10.2.2 .
Yes, I'm trying to find the layer index in ArcMap > Table of Contents in "List by Drawing Order" mode, so that it includes Group layers.
If there's also a way to obtain an ID that uniquely identifies a Layer instance, that might be useful too, because the indexes will change if we insert/delete layers. But if there's no such ID, then I'll use the indexes.
I'll consider using the layer name, but it seems like multiple layers can have the same name.
I'll consider using the data source, but it seems like multiple layers can have the same data source as well.