title: Does anything already exist to flatten a mix of single instances and arrays of instances?
body: <p>I just wrote myself a utility function </p>
  
  <pre><code>    private static IEnumerable&lt;T&gt; Flatten&lt;T&gt;(params object[] items) where T : class
      {
          return items.SelectMany(c =&gt; c is T ? new[] {c as T} : (IEnumerable&lt;T&gt;) c);
      }
  </code></pre>
  
  <p>It allowed me to go from this:</p>
  
  <pre><code>        var lines = records
              .GroupBy(c =&gt; new {c.CODEID, c.DESCRIPTION})
              .SelectMany(c =&gt; 
                  new[] { string.Format(insertRecord, c.Key.CODEID, c.Key.DESCRIPTION) }
                  .Concat(c.Select(d =&gt; string.Format(insertDetail, d.CODEID, d.CODESEQ, d.DATAVALUE, d.DISPLAYVALUE)))
                  .Concat(new [] {Environment.NewLine}))
              ;
  </code></pre>
  
  <p>To this:</p>
  
  <pre><code>        var lines2 = records
              .GroupBy(c =&gt; new {c.CODEID, c.DESCRIPTION})
              .SelectMany(c =&gt; Flatten&lt;string&gt;(
                  string.Format(insertRecord, c.Key.CODEID, c.Key.DESCRIPTION),
                  c.Select(d =&gt; string.Format(insertDetail, d.CODEID, d.CODESEQ, d.DATAVALUE, d.DISPLAYVALUE)),
                  Environment.NewLine))
              ;
  </code></pre>
  
  <p>Before I commit such an obscure looking thing to my code base, I wanted to see if I was overlooking some other obvious way to avoid the use of <code>Concat</code> in the first way above...</p>
  
  <p>NOTE: maybe this belongs on code review... not sure</p>