title: Using C# linq, How can i group by specific item in array?
body: <p>I have an array of Project objects.  </p>
  
  <pre><code>IEnumerable&lt;Project&gt; projects = GetProjects();
  </code></pre>
  
  <p>Each Project has a property called "Applications" which is an array of strings.  </p>
  
  <pre><code>IEnumerable&lt;string&gt; applicationsForProject = project.Applications();
  </code></pre>
  
  <p>Some projects have 1 application (1 element in the array) but others have many.</p>
  
  <p>I want to group all of my projects by individual application so I can generate a view that looks like this:</p>
  
  <ul>
  <li>App 1: 10 projects</li>
  <li>App 2: 4 projects</li>
  <li>App 3: 5 projects</li>
  </ul>
  
  <p>If i do this:</p>
  
  <pre><code>var projectsByApp = projects.GroupBy(r=&gt;r.Applications);
  </code></pre>
  
  <p>that will group not by the distinct applications but by the list so I wind up getting duplicate rows in my view (since project 1 might have App1 and App 2 and project 2 might just have App 2)</p>
  
  <p>Is there any better way to group by distinct application name across the array of projects?</p>