Share via


Restituire l'intersezione tra set di due sequenze

Per restituire l'intersezione di due sequenze, usare l'operatore Intersect.

Esempio

In questo esempio viene usato Intersect per restituire una sequenza di tutti i paesi/aree in cui sono presenti sia Customers che Employees.

var infoQuery =
    (from cust in db.Customers
    select cust.Country)
    .Intersect
        (from emp in db.Employees
        select emp.Country)
;
Dim infoQuery = _
    (From cust In db.Customers _
     Select cust.Country) _
    .Intersect _
        (From emp In db.Employees _
         Select emp.Country)

In LINQ to SQL, l'operazione Intersect è ben definita solo nei set. mentre la semantica per i tipi multiset non è definita.

Vedi anche