title: Initialize elements with brackets like Lists in c#
body: <p>I was thinking about arrays and lists and wondering if and how classes can get an implementation to be initializable like them. Let's take this class as basis:</p>
  
  <pre><code>class TestClass
  {
      private List&lt;int&gt; Numbers = new List&lt;int&gt; ();
  
      // Insert code here
  }
  </code></pre>
  
  <p>What I would like to be able to do is to take the given values and internally fill my list.</p>
  
  <pre><code>TestClass test = new TestClass () { 2, 4, 7, 10 };
  </code></pre>
  
  <p>What would be normally possible is this:</p>
  
  <pre><code>List&lt;int&gt; test = new List&lt;int&gt; () { 2, 4, 7, 10 };
  </code></pre>
  
  <p>But I would like to have it for my own custom classes. The next question, which is optional, is if the same can be done for this syntax:</p>
  
  <pre><code>TestClass test = { 2, 4, 7, 10 };
  </code></pre>
  
  <p>I assume that is less likely to be possible. Note, these are different from this:</p>
  
  <pre><code>Cat cat = new Cat() { Name = "Sylvester", Age=8 };
  </code></pre>
  
  <p>These are direct and optional declarations of internal fields and properties.</p>
  
  <p><a href="https://docs.microsoft.com/de-de/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers" rel="noreferrer">See also MSDN for more info</a>.</p>