title: Linq query selecting comma separated list
body: <p>I have a list of objects where the object has a string property that is a comma separated list of numeric Ids.</p>
  
  <p>What is most efficient way to extract the comma separated values and get an int array?</p>
  
  <p>Currently my solution is this:</p>
  
  <pre><code>var allCsvs = objects
      .Select(o =&gt; o.IdCsv); // the IdCsv is a string property, ie "1,2,3,4,5"
  var allIds = string.Join(",", allCsvs);
  var idArray = allIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
      .Select(id =&gt; Convert.ToInt32(id));
  </code></pre>
  
  <p>Any ideas on how to improve performance here?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>The object might look like this:</p>
  
  <pre><code>class MyClass {
      public string IdCsv { get; set; }
  }
  </code></pre>
  
  <p>And an instance of this class may have its string property <code>IdCsv</code> set to something like this: <code>"1,2,3,4,5"</code></p>