title: Find Distinct elements from a List C#
body: <p>I have a class say named <code>Product</code></p>
  
  <pre><code>public class Product
  {
      public string Name{ get; set; }
  
      public int ProductId{ get; set; }
  
  }
  </code></pre>
  
  <p>I have a list of Products, with same <code>Name</code>, but different <code>ProductId</code>.</p>
  
  <p>I want to get distinct products from the list on <code>product.Name</code></p>
  
  <p>i.e. if the list is</p>
  
  <pre><code>var fullproductList = {
          Name: product,
          ProductId: 1
      }, {
          Name: product,
          ProductId: 2
      }, {
          Name: product,
          ProductId: 3
      };
  </code></pre>
  
  <p>I want any one the above product. </p>
  
  <p>I want to achieve this without looping like this:</p>
  
  <pre><code>List&lt;Product&gt; distinctProducts= new List&lt;Product&gt;();
  
  var distictproductName=fullSubjectList.Select(x =&gt; x.Name).Distinct().ToList();
  
  foreach (var item in distictproductName)
  {
      distinctProducts.Add(fullproductList.Where(x=&gt;x.Name==item).FirstOrDefault());
  }
  </code></pre>
  
  <p>Any suggestions?</p>