Is there a way to enter all cases in a switch statement?

Is there a way to enter all cases in a switch statement?

I'm working with a switch statement that sets certain properties of an object dependent on a case - a new requirement has came in to add a case statement 'All' to essentially execute all the cases to apply all the fields - used in exceptional cases.

I'm working with a switch statement that sets certain properties of an object dependent on a case - a new requirement has came in to add a case statement 'All' to essentially execute all the cases to apply all the fields - used in exceptional cases.

I can't really find a nice solution around this, each case statement is only setting 1-2 property values so it wouldn't be worth separating the logic into methods. However, I also don't want to have a load of duplicate code.

        var person = new Person();
        switch (PersonEnum)
        {
            case PersonEnum.Name:
                person.Name = ...
                break;
            case PersonEnum.Age: 
               person.Age = ...
               break;
             case PersonEnum.All:
               person.Name = ...         
               person.Age = ...
               break;

The example code above is a far more simplified version of what I'm dealing with, but the idea still applies.

c-sharp .net

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five. 아시죠? C는 C++.C# 줄인말이 아니라는거?

Learn how to perform CRUD operations using C Sharp

QuickStart: CRUD Operations in C Sharp. Learn how to perform CRUD operations using C Sharp for MongoDB databases.

How to creating a Fluent API class in C#.NET

In this article we will look at creating a Fluent API class in C#.NET. In a Fluent API, we can link together different functionality to get a particular result. We see this used many times in Entity Framework Core and when manipulating List<T> type of items using lambda expressions.

Pixel Color Bot in C#, Visual Studio, .NET and WPF

Create a Pixel Color Bot in C# Visual Studio by using the .NET framework and WPF. This C# tutorial guides you through the development process of creating a pixel bot.

Loops in C++ | For, While, and Do While Loops in C++

In this Video We are going to see how to use Loops in C++. We will see How to use For, While, and Do While Loops in C++.