You cannot use object initializers ( new T { Property = value } ) unless you write for C # 3.0 or higher.
Unfortunately, for pre-C # 3.0 you will need to do:
ClaimsRequest cr = new ClaimsRequest(); cr.Country = DemandLevel.Request; cr.Email = DemandLevel.Request; cr.Gender = DemandLevel.Require; cr.PostalCode = DemandLevel.Require; cr.TimeZone = DemandLevel.Require; request.AddExtension(cr);
Here is a bit more about object initializers.
The easiest way to tell which version of C # you are using is to see which version of Visual Studio you are using. C # 3.0 came bundled with Visual Studio 2008.
However, you have a way out. Prior to .NET 4.0, but after .NET 2.0, all of the new language and framework features were actually managed libraries that were on top of the 2.0 CLR. This means that if you download the C # 3.0+ compiler (as part of a later version), you can compile your code with this compiler. (This is not so difficult to do in ASP.NET.)
source share