title: How to Select feature and highlight in ArcGIS using C#
body: <p>Hi I have the following code below for zooming into an arcGIS object based on the attribute now all I need is to be able to highlight that area with a select feature (The feature where you right-click on the area on the map and do select feature). </p>
  
  <p>Currently I have an event which will do the zoom.I want to add this select to the same attribute as well.</p>
  
  <p>Thank you in advance!!!</p>
  
  <pre><code>ESRI.ArcGIS.Carto.ILayer layer = GetLayersClass.GetFieldBoundaryLayer;
  if (layer is ESRI.ArcGIS.Carto.IGroupLayer)
  {
      ESRI.ArcGIS.Carto.IGroupLayer groupLayer = layer as ESRI.ArcGIS.Carto.IGroupLayer;
      ICompositeLayer pCompositeLayer = layer as ICompositeLayer;
      int layers = pCompositeLayer.Count;
      ILayer pLayer = pCompositeLayer.Layer[0];
  
      IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer;
  
      IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
      IQueryFilter pFilter = new QueryFilterClass();
      pFilter.WhereClause = "RightID = '" + selectedRightID.ToString() + "'";
  
      IFeatureCursor pFeatureCursor = pFeatureClass.Search(pFilter, false);
      IFeature pFeature = pFeatureCursor.NextFeature();
  
      if (pFeature == null)
      {
          System.Windows.Forms.MessageBox.Show("This section doesn't exist");
          return;
      }
  
      IApplication m_application = ArcMap.Application;
      IMxDocument pMxDoc = (IMxDocument)m_application.Document;
      IActiveView pActiveView = (IActiveView)pMxDoc.FocusMap;
  
      IEnvelope pEnv = pFeature.Shape.Envelope;
      pEnv.Expand(1.1, 1.1, true);
  
      pActiveView.Extent = pEnv;
  
      pActiveView.Refresh();
  </code></pre>
  
  <p>I tried by adding this code which I think will add the particular feature to the selection.
  but no luck with that as well.</p>
  
  <pre><code>IFeatureSelection pfeatSelect = pFeatureLayer as IFeatureSelection;
  pfeatSelect.Add(pFeature);
  </code></pre>