ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / SelectionSet Class / ToDictionary Method / ToDictionary<T>() Method
Example

In This Topic
    ToDictionary<T>() Method
    In This Topic
    Creates the dictionary of mapMembers and their corresponding objectIDs.
    Syntax
    public Dictionary<T,List<long>> ToDictionary<T>()
    where T: MapMember
    Public Overloads Function ToDictionary(Of T As MapMember)() As Dictionary(Of T,List(Of Long))

    Type Parameters

    T

    Return Value

    Dictionary of mapMembers and their corresponding objectIDs.
    Example
    Load map selection into Inspector
    // get the currently selected features in the map
    var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();
    // get the first layer and its corresponding selected feature OIDs
    var firstSelectionSet = selectedFeatures.ToDictionary().First();
    
    // create an instance of the inspector class
    var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();
    // load the selected features into the inspector using a list of object IDs
    await inspector.LoadAsync(firstSelectionSet.Key, firstSelectionSet.Value);
    Get selected feature's attribute value
    QueuedTask.Run(() =>
    {
    
      // get the currently selected features in the map
      var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();
    
      // get the first layer and its corresponding selected feature OIDs
      var firstSelectionSet = selectedFeatures.ToDictionary().First();
    
      // create an instance of the inspector class
      var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();
    
      // load the selected features into the inspector using a list of object IDs
      inspector.Load(firstSelectionSet.Key, firstSelectionSet.Value);
    
      //get the value of
      var pscode = inspector["STATE_NAME"];
      var myGeometry = inspector.Shape;
    });
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also