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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:24:59+00:00 2026-05-27T15:24:59+00:00

I wonder if there is an implementation of IDictionary interface in the standard library

  • 0

I wonder if there is an implementation of IDictionary interface in the standard library that has property IsFixedSize == true.

In my code, I am using a Dictionary indexed by an enum, like this:

Dictionary<EMyEnum, string> myDictionary = new Dictionary<EMyEnum, string>();

I always have values in the dictionary for all possible values of MyEnum, using a code like this:

    foreach (EMyEnum myEnum in Enum.GetValues(typeof(EMyEnum)))
    {
        m_myDictionary.Add(myEnum, "");
    }

so my dictionary actually has a fixed size. It feels kind of ‘wrong’ to be using Dictionary for it and I am wondering if there is perhaps a better type I am missing.

I was looking in System.Collections.Generic and System.Collections namespaces but could not find anything suitable.

In response to one of the questions, the enum is just a bunch of values, like this:

enum EMyEnum
{
    meValue1,
    meValue2,
    meValue3
}

EDIT:

I have accepted supermem’s answer as it is most to the point of the original question. To elaborate my original concern, an ordinary dictionary can have one of the keys/items deleted and then any code that relies on the fact that iterating over keys of the dictionary also iterates over all values of enum will be broken.

I understand that I can create a fixed size array but casting enums to ints is not that pretty, besides it would only work for contiguous enums (good enough in my case).

I think there is a good case for Dictionary that has enum values as keys and it is a pity that such a class does not ship with .Net.

  • 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-05-27T15:25:00+00:00Added an answer on May 27, 2026 at 3:25 pm

    No, there are no fixed size IDictionary implementations shipping with the CLR. (Except for the ReadOnly* sort, but not applicable to your problem.)

    You can roll your own, but unless you have profiled this code and determined that the use of Dictionary presents a meaningful bottleneck (IMO, very rare), I’d say to keep it as is. You also have the benefit of readability as Dictionary is very well understood and easy to grok.

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

Sidebar

Related Questions

We currently using openssl for timestamping. I wonder, is there a Java implementation of
I wonder if there's a List implementation allowing fast contains . I'm working with
I wonder, if someone could help me... Is there a LINQ query that will
Hi all! I wonder if there is a generally preferred implementation paradigm to respect
I wonder if there is an ongoing opensource project somewhere that mimics the MVC
I wonder if there's any good way to reuse data between implementation and description
I wonder if there are anything like a Javascript template system that wraps HTML,
I wonder there might be a built-in feature in Groovy, something like aCollection.doEachBulk(100) {
I just wonder there a way to display the files in document directory with
I wonder if there is better way to get max from column c1 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.