Find Distinct elements from a List C# -


I have a class named product

  Public category product {get public string name { Set; } Public int ProductId {get; Set; }}   

I have a list of products, along with name , but different ProductId .

I want to get a different product from the list at product.Name

I if list

  var fullproductList = {Name: Product, Product ID: 1}, {Name: Product, Product ID: 2}, {Name: Product, Product ID: 3};   

I would like any of the above product.

I want to get it without looping like this:

  list & gt; Products & gt; Specific Products = New List & lt; Products & gt; (); Var distictproductName = fullSubjectList.Select (x => x.Name). Undoubtedly (). ToList (); Foreign objects (different items distictproductName) {different products.ed (fullproduct list. Where (x => x.Name == item). First and default ()); }   

Any suggestions?

using separate with lambda:

  Full Subject List. Distinction (x = & gt; x.Name). Ollist ();    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -