title: Custom Collection Initializers
body: <p>Classes that implement <code>IEnumerable</code> and provide a <code>public void Add(/* args */)</code> function can be initialized like in the following example:</p>
  
  <pre><code>List&lt;int&gt; numbers = new List&lt;int&gt;{ 1, 2, 3 };
  </code></pre>
  
  <p>which calls the <code>Add(int)</code> function 3x after initializing the <code>List&lt;int&gt;</code>.</p>
  
  <p>Is there a way to define this behavior explicitly for my own classes? For example, could I have the initializer call a function other than the appropriate <code>Add()</code> overload?</p>