Get List<int> from List<Customer> using linq
c#, c#-3.0, linq
Solution
Try this:
List<int> customerIds = customerList.Select(c => c.Id).Distinct().ToList();
The code assumes that your customer object has an Id property which returns an int.
Problem
I have list of `customer` and want its `id` in separate list `List<int>`. I tried using: ``` customerList.Cast<int>.Distinct().ToList() ``` But it dosn't work. I also want distinct customer int list. How can I do that using `LINQ` syntax? What changes should I do in my query?