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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:03:05+00:00 2026-05-11T10:03:05+00:00

I doubt this is possible, but I was curious if you could have more

  • 0

I doubt this is possible, but I was curious if you could have more than 2 items (key,value) in a dictionary. Maybe a key and 2 values. Is there a collection object that does allow this? What I am actually trying to do is to store a key and a value for the key and another value to hold the count of how many times the key has been found. For example, I may have a for loop that goes through a list of colors and each color has a unique value. As I go through the list, I not only want to store the color, the unique value of the color in a dictionary, but also store how many times red occurred in the list.

I put in the following declaration and now I am tyring to figure out how I can test to see if it contains the value already and if it does not, add it to the list with a count of 1 and if it does, increment the count. After I post the declaration, I will post how I was doing it with just one dictionary.

Dictionary<string, Dictionary<int,int>> colors =                            new Dictionary<string, Dictionary<int,int>>(); 

Here is code of how I was handling it before:

Dictionary<string, int> colors = new Dictionary<string, int>();   foreach (Color color in ColorList)         {             if (colors.ContainsKey(color.ToString()))                 colors[color]++;             else                 colors.Add(color, 1);         } 
  • 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. 2026-05-11T10:03:06+00:00Added an answer on May 11, 2026 at 10:03 am

    Could you perhaps have a dictionary of a struct that would keep track of the color and the number of times it occurred?

    Edit: As suggested elsewhere, this could also be accomplished by building your own small custom class. Would essentially work in the same fashion.

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

Sidebar

Related Questions

Doubt this is possible as I don't have a 1 page app, but pretty
I doubt this is possible but what I would like to do is have
I doubt this is possible, but here's what I want to do. If my
I doubt this is possible but here goes. I need to formulate a SQL
I doubt this is possible, but it's worth asking: I'd like to call a
I doubt this is possible but I will ask it anyway, just in case,
This question has been asked again and again, but I have still a doubt.
I doubt this is possible, but just wanted to confirm. I am writing a
I doubt this is possible but, Is it possible to show a UIAlertView inside
I have doubt whether this is possible. I have two tables 1) file_master file_id

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.