title: Using Collection Initializer with System.Data.DataTable.Rows
body: <p>As far as I understand the use of a collection initializer is dependant on two things:</p>
  
  <ul>
  <li>The collection implements IEnumerable</li>
  <li>An Add() method</li>
  </ul>
  
  <p>As far as I can tell <code>System.Data.DataTable.Rows</code> satisfies both of the requirements, therefore I would expect I could do this:</p>
  
  <pre><code>DataRow row = _dt.Tables["TABLE"].NewRow();
  
  _dt.Tables["TABLE"].Rows =
  {
      row
  };
  </code></pre>
  
  <p>The compiler complains:</p>
  
  <ul>
  <li>Rows has no setter (but I'm not creating a new collection, merely adding to an existing one via the reference supplied</li>
  </ul>
  
  <p>Perhaps you could point out my mistake.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I've just realised my issue is with <code>DataRowCollection</code> which doesn't implement <code>IEnumerable</code> but <em>does</em> have an <code>Add()</code> method.  Therefore am I correct in thinking that this doesn't work purely because <code>IEnumerable</code> isn't implemented?  If so why can't it be added to the BCL?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Please see this code that shows you can add to an existing collection with an initializer:</p>
  
  <pre><code>        public class Person
          {
              public Person()
              {
                  friends.Add("Paul");
              }
  
              List&lt;string&gt; friends = new List&lt;string&gt;();
  
              public List&lt;string&gt; Friends
              {
                  get { return friends; }
              }
          }
  
          Person tom = new Person
          {
              //Adding to an existing collection NOT creating a new one
              Friends = {"Steve", "Jim", "John"}
          };
  </code></pre>