Liberally sprinkled through the code snippets provided in the ArcGIS Pro SDK there are several references to using:
Any idea on how to get it to work?
I'm attempting the following:
MapProjectItem mpi = Project.Current.GetItems<MapProjectItem>().FirstOrDefault(m => m.Name.Equals(strMapName, StringComparison.CurrentCultureIgnoreCase));
I'm using the above to retrieve the first occurrence of a map element in a project with the given name in an array that meets the search criteria. However, the above method is not part of the GetItems class. As a result Visual Studio returns "IEnumeratable<MapProjectItem> does not contain a definition for .FirstOrDefault and no accessible extension accepting a first argument could be found."
Solved! Go to Solution.
GetItems returns a type of
As Kris mentioned above if you include System.Linq you will get a set of extension methods for any object that implements the IEnumerable interface (and other interfaces and classes as well) as for example: Enumerable.FirstOrDefault Method (System.Linq) | Microsoft Docs
To understand LINQ (classes and interfaces that support queries that use Language-Integrated Query (LINQ)) better you can search for Microsoft for help on LINQ.