title: UNION from multiple lists
body: <p>I have a <code>class book</code> that has a property <code>IEnumerable&lt;string&gt; Tags</code>:</p>
  <pre><code>public class Book
  {
      public Book(string title, IEnumerable&lt;string&gt; tags)
          =&gt; (Title, Tags) = (title, tags);
  
      public string Title { get; }
      public IEnumerable&lt;string&gt; Tags { get; }
  }
  </code></pre>
  <p>Now I have <code>IEnumerable&lt;Book&gt; books</code> and I need to get only the common tags between <strong>ALL</strong> objects.</p>
  <pre><code>public static void TestMethod()
  {
      var book1 = new Book(&quot;Book1&quot;, new List&lt;string&gt; { &quot;c#&quot;, &quot;.net&quot;, &quot;programming&quot; });
      var book2 = new Book(&quot;Book2&quot;, new List&lt;string&gt; { &quot;ado&quot;, &quot;c#&quot; });
      var book3 = new Book(&quot;Book3&quot;, new List&lt;string&gt; { &quot;programming&quot;, &quot;c#&quot; });
      var book4 = new Book(&quot;Book4&quot;, new List&lt;string&gt; { &quot;ef-core&quot;, &quot;database&quot;, &quot;.net&quot; });
      var book5 = new Book(&quot;Book5&quot;, new List&lt;string&gt; { &quot;.net&quot;, &quot;visual-studio&quot;, &quot;c#&quot;, &quot;programming&quot; });
  
      var list1 = new List&lt;Book&gt; { book1, book2, book3 };
      var list2 = new List&lt;Book&gt; { book1, book3, book5 };
      var list3 = new List&lt;Book&gt; { book1, book4, book5 };
      var list4 = new List&lt;Book&gt; { book1, book2, book4 };
  
  
      // expected returns:
      // list1 =&gt; { &quot;c#&quot; }
      // list2 =&gt; { &quot;c#&quot;, &quot;programming&quot; }
      // list3 =&gt; { &quot;.net&quot; }
      // list4 =&gt; { }
  
      Console.WriteLine($&quot;list1 =&gt; {{{string.Join(';', GetCommonTags(list1))}}}&quot;);
      Console.WriteLine($&quot;list2 =&gt; {{{string.Join(';', GetCommonTags(list2))}}}&quot;);
      Console.WriteLine($&quot;list3 =&gt; {{{string.Join(';', GetCommonTags(list3))}}}&quot;);
      Console.WriteLine($&quot;list4 =&gt; {{{string.Join(';', GetCommonTags(list4))}}}&quot;);
  }
  
  </code></pre>
  <p>I really don't know the right way to do this. Until that moment, I do it in this horrible way (in Brazil, we call this &quot;gambiarra&quot;, or &quot;Workaround&quot; in english):</p>
  <pre><code>public static IEnumerable&lt;string&gt; GetCommonTags(IEnumerable&lt;Book&gt; books)
  {
      var allTags = books.SelectMany(b =&gt; b.Tags).Distinct();
      var commonTags = new List&lt;string&gt;();
  
      foreach (var tag in allTags)
      {
          var isCommonTag = true;
          foreach (var book in books)
          {
              if (!book.Tags.Contains(tag))
              {
                  isCommonTag = false;
                  break;
              }
          }
  
          if (isCommonTag) commonTags.Add(tag);
      }
  
      return commonTags;
  }
  </code></pre>
  <p>It's working, but how to do this right, or maybe with linq?</p>