how to find layer type of a layer

2448
2
Jump to solution
05-29-2014 09:17 AM
SeanNakasone
New Contributor II
How do I find a layer type of an ILayer?  For example, if I loop through all ILayers from an IMap, how do I determine whether each ILayer is an IGroupLayer ?

I already know I can use IMap.get_Layers(<IUID>, true) to obtain all the layers of a given type according to the passed IUID.

But I prefer to first obtain all layers, then determine what type of layer it is.
0 Kudos
1 Solution

Accepted Solutions
NeilClemmons
Regular Contributor III
In VB, use TypeOf to test if an object implements a particular interface.  In C# use Is.

If TypeOf yourLayer Is IGroupLayer Then...it's a group layer.
if (yourLayer is IGroupLayer) {...it's a group layer.

View solution in original post

0 Kudos
2 Replies
NeilClemmons
Regular Contributor III
In VB, use TypeOf to test if an object implements a particular interface.  In C# use Is.

If TypeOf yourLayer Is IGroupLayer Then...it's a group layer.
if (yourLayer is IGroupLayer) {...it's a group layer.
0 Kudos
SeanNakasone
New Contributor II
thank you very much, that works.
0 Kudos