---
title: "Get Duplicate field Name in single list"  
description: "Get Duplicate field Name in single list"  
author: "Anonymous User"  
published: 2014-08-29  
updated: 2014-09-01  
canonical: https://www.mindstick.com/forum/2200/get-duplicate-field-name-in-single-list  
category: "c#"  
tags: ["c#", "get duplicate field name", "single list", "Get Duplicate field Name in single list"]  
reading_time: 1 minute  

---

# Get Duplicate field Name in single list

I have a List<Car> lstcar with [properties](https://www.mindstick.com/articles/23331/nootropics-7-different-types-and-their-unique-properties)

[name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide)-Zen id-1211 MfYear-1990 [Color](https://www.mindstick.com/articles/77/how-to-split-form-background-color-in-c-sharp)-[black](https://yourviews.mindstick.com/view/83102/badi-elaichi-black-cardamom-health-benefits)

name-Alto id-1521 MfYear-1990 Color-black

name-[Nano](https://answers.mindstick.com/qa/37748/which-car-companies-has-launched-a-small-cheaper-car-nano) id-9911 MfYear-1990 Color-black

name-800 id-1721 MfYear-1990 Color-black

name-zen id-711 MfYear-1990 Color-black

name-[Swift](https://yourviews.mindstick.com/view/85535/explore-the-journey-of-taylor-swift-from-global-stardom-to-beginnings-in-nashville) id-9911 MfYear-1990 Color-black

name-Nano id-1081 MfYear-1990 Color-black

I want name of repeated [items](https://www.mindstick.com/forum/33812/getting-number-of-items-selected-in-uicollectionview-in-ios) based on name eg: I want "Zen , Nano", but when I do

List<Car> dup = lstcar.GroupBy(s => s.CarName)

.Select(grp => grp.FirstOrDefault())

.OrderBy(s => s.CarName)

.ToList<Car>();

I get dup has this [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages)

name-Zen id-1211 MfYear-1990 Color-black

name-Alto id-1521 MfYear-1990 Color-black

name-Nano id-9911 MfYear-1990 Color-black

name-800 id-1721 MfYear-1990 Color-black

name-Swift id-9911 MfYear-1990 Color-black

but I want

name-Zen id-1211 MfYear-1990 Color-black

name-Nano id-9911 MfYear-1990 Color-black

name-zen id-711 MfYear-1990 Color-black

name-Nano id-1081 MfYear-1990 Color-black

How do I get duplicates from one List<T> ?

## Replies

### Reply by Sumit Kesarwani

Add Where clause to get only groups with more then 1 element and SelectMany to flatten results into one list:

```
var duplications = lstcar.GroupBy(s => s.CarName)                        
.Where(g => g.Count() > 1)                        
.SelectMany(g => g)                        
.ToList();
```

I see you won't Zen and zen in the same group, so you should change your GroupBy to: GroupBy(s => s.CarName.ToLower())


---

Original Source: https://www.mindstick.com/forum/2200/get-duplicate-field-name-in-single-list

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
