ArcGIS Pro 2.6 API Reference Guide
GetLayersAsFlattenedList Method (Map)
Example 

ArcGIS.Desktop.Mapping Namespace > Map Class : GetLayersAsFlattenedList Method
Returns a read only flat list of layers where nested groups are not preserved.
Syntax
public IReadOnlyList<Layer> GetLayersAsFlattenedList()
Public Function GetLayersAsFlattenedList() As IReadOnlyList(Of Layer)

Return Value

A read only list of layers
Example
Find a layers using partial name search.
Map map = MapView.Active.Map;
IEnumerable<Layer> matches = map.GetLayersAsFlattenedList().Where(l => l.Name.IndexOf(partialName, StringComparison.CurrentCultureIgnoreCase) >= 0);
Get a list of layers filtered by layer type from a map.
List<FeatureLayer> featureLayerList = aMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().ToList();
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 7

See Also

Reference

Map Class
Map Members