2013-02-16 7 views

Odpowiedz

5
List<DateTime> common = list1.Intersect(list2).Intersect(list3).ToList(); 
1
var resultSet = list1.Intersect<DateTime>(list2).Intersect<DateTime>(list3); 
1

Można przecinać list:

var resultSet = list1.Intersect<DateTime>(list2); 
var finalResults = resultSet.Intersect<DateTime>(list3); 

foreach (var result in finalResults) { 
    Console.WriteLine(result.ToString()); 
} 
2
HashSet<DateTime> common = new HashSet<DateTime>(list1); 
common.IntersectWith(list2); 
common.IntersectWith(list3); 

Klasa HashSet jest bardziej efektywne dla takich zadań niż przy użyciu Enumerable.Intersect.

Aktualizacja: upewnij się, że wszystkie twoje wartości są takie same DateTimeKind.

Powiązane problemy