public ILayer GetLayerFromMapByName(IMap map, string name) { for (int x = 0; x < map.LayerCount; x++) { var layer = map.get_Layer(x); if (layer == null || layer.Name != name) continue; return layer; } return null; }