How to Get the selected Object when Deselected Object using C#?

Is there any simply way to get the selected RhinoObject when Deselected RhinoObject? My Code is like as follow:

 private void DisplayUserDict_Deselect(object sender, RhinoObjectSelectionEventArgs e)
            List<RhinoObject> RhinoObjs = e.RhinoObjects.ToList();
            RhinoObject[] TempRhinoObjs = HasSelectedRhinoObjs.ToArray();
            foreach(RhinoObject item in RhinoObjs)
                string _Id1 = item.Id.ToString();
                foreach(RhinoObject item2 in TempRhinoObjs)
                    string _Id2 = item2.Id.ToString();
                    if (_Id1 == _Id2) HasSelectedRhinoObjs.Remove(item2);
            List<GeometryBase> HasSelectGeoms = (from item in HasSelectedRhinoObjs
                                               where item.Geometry as GeometryBase != null
                                               select item.Geometry).ToList();

But I think it is so complex to get the selected RhinoObject When Deselected an Object.

Hi @cughudson,

This may be a bit more efficient:

private void RhinoDoc_DeselectObjects(object sender, RhinoObjectSelectionEventArgs e)
  m_selected_objects.RemoveAll(x => e.RhinoObjects.Contains(x));
  // todo...

– Dale


ThankYou, VeryMuch

I’ll Have A Try