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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:23:42+00:00 2026-06-05T17:23:42+00:00

The class looks as follows: public static class CacheManager { private static Dictionary<string, object>

  • 0

The class looks as follows:

public static class CacheManager
{
    private static Dictionary<string, object> cacheItems = new Dictionary<string, object>();

    private static ReaderWriterLockSlim locker = new ReaderWriterLockSlim();

    public static Dictionary<string, object> CacheItems
    {
        get
        {
            return cacheItems;
        }
    }
    ...
}

The ReaderWriterLockSlim locker object should be used as well.

The client looks as follows now:

foreach (KeyValuePair<string, object> dictItem in CacheManager.CacheItems)
{
    ...
}

Thank you in advance.

  • 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-05T17:23:46+00:00Added an answer on June 5, 2026 at 5:23 pm

    If you only need to iterate the contents, then frankly it isn’t really being used as a dictionary, but an iterator block and indexer might be used to hide the internal object:

    public IEnumerable<KeyValuePair<string, object>> CacheItems
    {
        get
        { // we are not exposing the raw dictionary now
            foreach(var item in cacheItems) yield return item;
        }
    }
    public object this[string key] { get { return cacheItems[key]; } }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My class looks like this. public class LogSettings { public string attributeName { get;
I have a class that looks like the following: public class MyClass { private
Assume I have a class that looks like this: class Sample { public string
I have a class ThreadClass which looks as follows: public class ThreadClass extends Thread{
I'm using ASP.NET MVC 3. I've wriiten a helper class as follows: public static
Suppose my repository class looks like this: class myRepository : IDisposable{ private DataContext _context;
I have a class that looks like this: public class BasePadWI { public WorkItem
Currently I have a class that looks like this: public class MyClass : IMyClass
We have a class a class that looks something like the following: public class
I have code that looks like follows: public interface BaseDAO{ // marker interface }

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.