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 7830207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:07:28+00:00 2026-06-02T11:07:28+00:00

Is there a C# construct like the switch statement that allows control to fall

  • 0

Is there a C# construct like the switch statement that allows control to fall through the next level? I have something like this:

    public static IEnumerable<string> SeverityOrHigher(string severity)
    {
        var result = new List<string>();

        switch (severity.ToUpper())
        {
            case "ALL":
                result.Add("ALL");
            case "DEBUG":
                result.Add("DEBUG");
            case "INFO":
                result.Add("INFO");
            case "WARN":
                result.Add("WARN");
            case "ERROR":
                result.Add("ERROR");
            case "FATAL":
                result.Add("FATAL");
            case "OFF":
                result.Add("OFF");
            default:
                break;
        }

        return result;
    }

…which clearly does not work in C#, (Control cannot fall through from one case label...) yet it seems to me like it should. I know it expects breaks in there, but that would not give me the data flow I’m looking for. What can be done to make this happen the way I’d like?

  • 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-06-02T11:07:36+00:00Added an answer on June 2, 2026 at 11:07 am

    In your case you can emulate “falling case” with a little bit of LINQ:

    public static IEnumerable<string> SeverityOrHigher(string severity)
    {
        var result = new List<string>() 
            { "ALL", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "OFF" };
        return result.SkipWhile(l => l != severity.ToUpper()).ToArray();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I everyone i have a JSON Array that is construct like this for (var
I'm wondering if there is any JPQL construct that might help me with this
Is there an add-in for the VSIDE that allows you to visually construct ASP.NET
I'm working on upgrading a library that looks something like this (in coffeescript for
Is there a language construct in C# that allows the abstraction of loop (or
I wanted to avoid the switch statement. I have over 30 document types. There
I have a class with a construct like this: private static Dictionary<Contract, IPriceHistoryManager> _historyManagers
I have a polygon soup of triangles that I would like to construct a
I have trees like this one: $tree = array(A, array( array(B, 1), array(C, 2),
I have an action sheet with options that vary depending on the circumstances. There

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.