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

  • SEARCH
  • Home
  • 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 116023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:06:44+00:00 2026-05-11T03:06:44+00:00

Why does the compiler say a constant value is required for the first case…the

  • 0

Why does the compiler say ‘a constant value is required’ for the first case…the second case works fine…

switch (definingGroup) {     case Properties.Settings.Default.OU_HomeOffice:           //do something           break;     case 'OU=Home Office':           //do something         break;     default:         break;  } 

also tried…

switch (definingGroup) {     case Properties.Settings.Default.OU_HomeOffice.ToString():           //do something         break;     case 'OU=Home Office':         //do something         break;     default:         break;  } 

…same error

Here’s the Properties.Setting code

[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute('OU=Home Office')] public string OU_HomeOffice {     get {         return ((string)(this['OU_HomeOffice']));     } } 
  • 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. 2026-05-11T03:06:45+00:00Added an answer on May 11, 2026 at 3:06 am

    Properties.Settings.Default.OU_HomeOffice isn’t a constant string – something known at compile time. The C# switch statement requires that every case is a compile-time constant.

    (Apart from anything else, that’s the only way it can know that there won’t be any duplicates.)

    See section 8.7.2 of the C# 3.0 spec for more details.

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

Sidebar

Related Questions

Say I have a loop like for (Foo aType : bar.getAList()) { if (aType.getBaz().equals(baz))
Probably a simple question: Why do I get an compiler warning for the following
Say I have a class like this: @interface MyAwesomeClass : NSObject { @private NSString
Possible Duplicate: or is not valid C++ : why does this code compile ?
The const modifier in C++ before star means that using this pointer the value
How do I build Linq Expressions for aggregate classes? Let me explain with an
Hi I have a program that deals alot with vectors and indexes of the
When I open up a Asp Net web site of mine in Visual Studio
MSDN categorizes var under Types . variables that are declared at method scope can
This is another of those SCJP questions. The code below prints Alpha:fooBeta:fooBeta:barBeta:bar , and

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.