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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:37:01+00:00 2026-06-15T01:37:01+00:00

I have declared a dictionary in the following way : public static Dictionary<string,bool> Features

  • 0

I have declared a dictionary in the following way :

public static Dictionary<string,bool> Features {get;set;}

After this dictionary is populated it has following values :

**[Key],[Value]**
module1.add,true
module1.update,true
module1.delete,true
module1.save,true
module1.clear,true
module2.add,true
module2.update,true
module2.delete,true
module2.save,true
...
module10.add,true
module10.update,true
module10.delete,true
module10.save,true

After it is populated, i need to iterate over dictionary key and update dictionary values.

Ex : wherever i have .add and .delete in key, its value needs to be updated to false.

after update, it must look like this

module1.add,false
module1.update,true
module1.delete,false
module1.save,true
module1.clear,true
module2.add,false
module2.update,true
module2.delete,false
module2.save,true
...
module10.add,false
module10.update,true
module10.delete,false
module10.save,true

Let me know how to iterate through the dictionary and update the value in C#.
Your help is appreciated.

  • 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-15T01:37:02+00:00Added an answer on June 15, 2026 at 1:37 am

    This will get all the keys that end in .add or .delete and update their values to false.

    Features.Keys.Where(v => v.EndsWith(".add") || v.EndsWith(".delete"))
        .ToList().ForEach(v => Features[v] = false);
    

    Here it is without linq:

    var targetFeatuers = new List<string>();
    foreach (var feature in Features.Keys)
    {
        if (feature.EndsWith(".add") || feature.EndsWith(".delete"))
        {
            targetFeatuers.Add(feature);
        }
    }
    
    foreach (var feature in targetFeatuers)
    {
        Features[feature] = false;
    }
    

    Note that you have to create the separate list of keys to avoid modifying the collection as you enumerate it.

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

Sidebar

Related Questions

I have a dictionary declared like this. public static Dictionary<int?, List<int?>> pegMap = new
I have code where this is declared: public IDictionary<string, OPTIONS> dict_Options = new Dictionary<string,
I have this dictionary mappings declared as a Dictionary<string, HashSet<string>> . I also have
Suppose that I have a Dictionary<string, string> . The dictionary is declared as public
I have declared a dictionary like this: Dictionary<string, KeyValuePair<string, string>> dc = new Dictionary<string,
I have a dictionary (formatters) declared in the following code that will have items
If I have a dictionary with the following key/value foo/bar and declared [dictionary setObject:@baz
i have a TDictionary declared like so TDictionary<String,Integer> , Now i want to get
Currently, in my C# .cs file, I have declared a dictionary as such: Dictionary<string,
I have a Dictionary that is declared thusly: Dictionary myDictionary<string, List<FCPort>> = new Dictionary<string,

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.