title: Generic list adds null values in c#
body: <p>I have a generic list called connectedEntites and I add items to this list in a for loop. I do a null check before adding. But even then whenever an item is added to this <code>List&lt;&gt;</code> a null value is also added. I did debug but there is noway a null value can be added. Due to this null value when i perform read operation the program crashes (as this is a COM program). </p>
  
  <p>Below is the code for the class</p>
  
  <pre><code>public class EntityDetails
  {
      public ObjectId objId { get; set; }
      public Handle objHandle { get; set; }
      public string className { get; set; }
  
      public override bool Equals(object obj)
      {
          if (obj == null) return false;
          EntityDetails objAsEntityDetails = obj as EntityDetails;
          if (objAsEntityDetails == null) return false;
          else return Equals(objAsEntityDetails);
      }
  
      public bool Equals(EntityDetails other)
      {
          if (other == null)
              return false;
  
          return (this.objId.Equals(other.objId));
      }
  }`
  </code></pre>
  
  <p>Below is the image where you can see the null values and the capacity also doubles as the item is added, but the count shows correct value.</p>
  
  <p><img src="https://i.stack.imgur.com/LarBX.png" alt="Generic List in Debug Mode"></p>