Finding Common Values in Two Lists in C# Using LINQFiled Under: .NET
Finding common values in two lists is simple in .NET 3.5 thanks to LINQ! I found this example here and here.
In practice here is what I did:
var currentOperatorFacilityIds = from fac in Facility.Facility.ListAllForOperator(this.OperatorId) select fac.ID; var deleteOperatorFacilityIds = from fac in Facility.Facility.ListAllForOperator(operatorId) select fac.ID; var commonFacilityIds = currentOperatorFacilityIds.Intersect(deleteOperatorFacilityIds);
Really simple! I love LINQ.
- Permalink
- eric
- 19 Jun 2008 4:46 PM
- Comments (1)
June 20th, 2008 at 9:11 pm
[...] First blog post in almost seven months; quick LINQ thing. http://willcodeforcoffee.co... [...]