> For the complete documentation index, see [llms.txt](https://dailyjournal.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dailyjournal.gitbook.io/notes/languages/c-sharp/features/linq/operators.md).

# Operators

## Joins

```csharp
var leftOuterJoin = 
    from l in leftCollection
    join r in rightCollection on l.Key equals r.Key into joined
    from r in joined.DefaultIfEmpty()
    select new { l, r };
```

## Quantifier Operations

<table><thead><tr><th width="162">Method Name</th><th>Description</th></tr></thead><tbody><tr><td><code>All</code></td><td>Determines whether all the elements in a sequence satisfy a condition.</td></tr><tr><td><code>Any</code></td><td>Determines whether any elements in a sequence satisfy a condition.</td></tr><tr><td><code>Contains</code></td><td>Determines whether a sequence contains a specified element.</td></tr></tbody></table>

## Set Operations

<table><thead><tr><th width="166">Method names</th><th>Description</th></tr></thead><tbody><tr><td><code>Distinct</code> or <code>DistinctBy</code></td><td>Removes duplicate values from a collection.</td></tr><tr><td><code>Except</code> or <code>ExceptBy</code></td><td>Returns the set difference, which means the elements of one collection that do not appear in a second collection.</td></tr><tr><td><code>Intersect</code> or <code>IntersectBy</code></td><td>Returns the set intersection, which means elements that appear in each of two collections.</td></tr><tr><td><code>Union</code> or <code>UnionBy</code></td><td>Returns the set union, which means unique elements that appear in either of two collections.</td></tr></tbody></table>

```csharp
string[] planets = { "Mercury", "Venus", "Venus", "Earth", "Mars", "Earth" };
string[] planets2 = { "Mercury", "Earth", "Mars", "Jupiter" };

IEnumerable<string> distinctMethod = from planet in planets.Distinct()
                            select planet;
IEnumerable<string> exceptMethod = from planet in planets1.Except(planets2)
                            select planet;
IEnumerable<string> exceptMethod = from planet in planets1.Intersect(planets2)
                            select planet;
IEnumerable<string> exceptMethod = from planet in planets1.Union(planets2)
                            select planet;
                            
foreach (var str in distinctMethod)
    Console.Write(str + " ");

/* Distinct() Output : Mercury Venus Earth Mars */
/* Except() Output : Venus */
/* Intersect() Output : Mercury Earth Mars */
/* Union() Output : Mercury Venus Earth Mars Jupiter*/
```
