title: C# syntax to initialize custom class/objects through constructor params in array?
body: <p>I have a class with minimum 4 variables and I have made a constructor for the class so that I can initialize it with</p>
  <pre><code>MyClass testobj = new MyClass(1234,56789,&quot;test text&quot;, &quot;something else&quot;, &quot;foo&quot;);
  </code></pre>
  <p>Works fine.</p>
  <p>Then I have an array of these, that I need to parse in a loop, so I would like to get some static data into this array.</p>
  <p>My approach was:</p>
  <pre><code>MyClass[] testobjlist = new MyClass 
  {
       new MyClass(1001,1234,&quot;Text 1&quot;, &quot;abcdefghijklm&quot;, &quot;ding&quot;),
       new MyClass(1002,2345,&quot;Text xx&quot;, &quot;bla bla&quot;, &quot;dong&quot;),
       new MyClass(1003,8653,&quot;Text yy&quot;, &quot;blah blah even more&quot;, &quot;bamm!&quot;)
  };
  </code></pre>
  <p>but somehow this gives me a weird error about me needing an extra } ???</p>
  <blockquote>
  <p>Compilation Error</p>
  <p>Description: An error occurred during the compilation of a resource
  required to service this request. Please review the following specific
  error details and modify your source code appropriately.</p>
  <p>Compiler Error Message: CS1513: } expected</p>
  <p>Source Error:</p>
  <p>Line 151:          }<br />
  Line 152:        }<br />
  Line 153:}</p>
  </blockquote>
  <p>I don't know if I should mention this, but I use it for webpages using Razor-engine 2. But I think this is an ordinary C# question?</p>
  <p>My workaround is currently to initialize the array with a size, then adding the elements one by one through index, but I would rather prefer the above solution as I might have to move the items up and down in order when testing and I have a lot more than 3 in the real data.</p>
  <p>Wondering what I am missing in the above code?</p>