Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6934709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:59:44+00:00 2026-05-27T11:59:44+00:00

When compiling some C# code, I get the error: A new expression requires ()

  • 0

When compiling some C# code, I get the error:

A new expression requires () or [] after type

My code is as follows:

request.AddExtension(new ClaimsRequest {
        Country = DemandLevel.Request,
        Email = DemandLevel.Request,
        Gender = DemandLevel.Require,
        PostalCode = DemandLevel.Require,
        TimeZone = DemandLevel.Require,
});

I am working with ASP.NET 2.0.

Can you help explain why this error occurs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:59:45+00:00Added an answer on May 27, 2026 at 11:59 am

    You cannot use object initializers (new T { Property = value }) unless you are writing for C# 3.0 or above.

    Unfortunately, for pre-C# 3.0, you’ll 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);
    

    A bit more about object initializers here.

    The easiest way to tell what version of C# you are using is by looking at what version of Visual Studio you are using. C# 3.0 came bundled with Visual Studio 2008.

    You do have a “way out” however. Prior to .NET 4.0 but after .NET 2.0, all new language and framework features were actually just managed libraries that sat on top of version 2.0 of the CLR. This means that if you download the C# 3.0+ compiler (as part of a later framework), you can compile your code against that compiler. (This is not trivial to do in an ASP.NET environment.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When compiling some CUDA code, I get the error, that the libcutil cannot be
I'm having trouble compiling some C code. When I compile, I'l get this error:
I'm compiling some C code, and I get the error typedef 'A' is initialized
I'm compiling some code which uses libcurl on a Debian Linux system. My dev
I'm working on re-compiling some Pro*C code that no one currently at my company
I'm compiling some C# and VB code at run time using the CodeDomProvider, CompilerInfo,
I generate some code using CXF from a WSDL-file. When compiling the code with
I was trying to speed up some code, and then I tried compiling a
Greetings, SO. I have some code which I've made attempts at compiling using gcc,
when compiling some projects on linux terminal, I get usually a long output consisting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.