You can use grouping, and get the first car from each group:
List<Car> distinct =
cars
.GroupBy(car => car.CarCode)
.Select(g => g.First())
.ToList();
More Related Contents:
- LINQ’s Distinct() on a particular property
- LINQ Select Distinct with Anonymous Types
- linq distinct or group by multiple properties
- Get a list of distinct values in List
- How to use LINQ Distinct() with multiple fields
- Get all checked nodes of a treeview
- Difference Between Select and SelectMany
- How do I use LINQ Contains(string[]) instead of Contains(string)
- Sequence contains no elements?
- Concat all strings inside a List using LINQ
- Func with out parameter
- Sorting a list using Lambda/Linq to objects
- Determine if a sequence contains all elements of another sequence using Linq [duplicate]
- How to Bulk Update records in Entity Framework?
- Linq order by, group by and order by each group?
- LINQ Inner-Join vs Left-Join
- Find character with most occurrences in string?
- Why use AsQueryable() instead of List()?
- C#: How to convert a list of objects to a list of a single property of that object?
- linq group by contiguous blocks
- convert this LINQ expression into Lambda
- how do I chunk an enumerable?
- Code equivalent to the ‘let’ keyword in chained LINQ extension method calls
- How to sort a dictionary by key
- LINQ performance Count vs Where and Count
- Issues Doing a String Comparison in LINQ
- Select all columns after JOIN in LINQ
- Select multiple fields group by and sum
- Linq – Top value from each group
- C# Searching for files and folders except in certain folders