title: A new expression requires () or [] after type compilation error - C#
body: <p>The following code for a co-worker throws the following error when he tries to compile it using VS 2008:</p>
  
  <p>Error:</p>
  
  <blockquote>
    <p>A new expression requires () or []
    after type</p>
  </blockquote>
  
  <p>Code:</p>
  
  <p>MyClass Structure:</p>
  
  <pre><code>public class MyClass
  {
      public MyClass() {}
  
      public string Property1 { get; set; }
      public string Property2 { get; set; }
  }
  </code></pre>
  
  <p>Sample Source Code:</p>
  
  <pre><code>List&lt;MyClass&gt; x = new List&lt;MyClass&gt;();
  
  x.Add(new MyClass 
  {
      Property1 = "MyValue",
      Property2 = "Another Value"
  });
  </code></pre>
  
  <p>It "works on my machine", but not his.  Any idea why?</p>
  
  <p><B>UPDATE</B><br /> 
  He is targeting the 3.5 .NET framework<br /> 
  He is using the System.Collections.Generics namespace<br />
  The MyClass object does have a constructor</p>
  
  <p><b>UPDATE 1:</b><br />
  @Funky81 - Your example and my example were able to compile on my PC.</p>
  
  <p><b>Update 2:</b><br /> 
  Included schema of MyClass in sample</p>
  
  <p><B>UPDATE 3:</b><br />
  @DK - I had my co-worker add the following configuration section to his application:</p>
  
  <pre><code>&lt;system.codedom&gt;
          &lt;compilers&gt;
              &lt;compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt;
                  &lt;providerOption name="CompilerVersion" value="v3.5"/&gt;
                  &lt;providerOption name="WarnAsError" value="false"/&gt;
              &lt;/compiler&gt;
              &lt;compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"&gt;
                  &lt;providerOption name="CompilerVersion" value="v3.5"/&gt;
                  &lt;providerOption name="OptionInfer" value="true"/&gt;
                  &lt;providerOption name="WarnAsError" value="false"/&gt;
              &lt;/compiler&gt;
          &lt;/compilers&gt;
      &lt;/system.codedom&gt;
  </code></pre>
  
  <p>And he received the following compilation error: Unrecognized element 'providerOption'.</p>