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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:33:12+00:00 2026-06-02T08:33:12+00:00

I am looking for a solution that lets me store and lookup multiple tuples.

  • 0

I am looking for a solution that lets me store and lookup multiple tuples. Dictionary only provides a simple way to lookup keys but not the values. I understand why (non-uniqueness possibility of values). However, what if each and every entry (keys and values) are strictly unique. Is there a collection that easily lets me store and lookup whatever key I chose and returns the matching field of such key? When looking up values I would necessarily have to specify the key field and the desired lookup field. I target C# 4.0

Example:

Collection<string, int, myEnum> myCollection = new ...

myCollection.Add("abc", 5, myEnum.First);
myCollection.Add("def", 6, myEnum.Second);

myCollection[int, myEnum, 6] = Second (of type myEnum) -> I just made up the way how a key and value field could be specified. Does such collection exist or would I need to roll my own?

I understand I am getting into the concept of tables but would like to avoid using a table structure if at all possible.

Note: The number of tuples will be limited to <20 (so if I rolled my own I would not be overly concerned with having to loop but I look for something more elegant)

Thanks

  • 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-02T08:33:13+00:00Added an answer on June 2, 2026 at 8:33 am

    You can just a hashset with a tuple. Like this:

    var hs=new HashSet<Tuple<string,int,myEnum>>();
    

    then to add you do this (the add function is O(1)):

    hs.Add(new Tuple<string,int,myEnum>("abc", 5, myEnum.First));
    hs.Add(new Tuple<string,int,myEnum>("def", 6, myEnum.Second));
    

    to look up the tuple you do this (the contains function is O(1)):

    var tupleTolookUp=new Tuple<string,int,myEnum>("abc", 5, myEnum.First);
    if(hs.Contains(tupleTolookUp))
    {
        //do what ever with the tupleTolookUp
    }
    

    In the hashset the Tuples has to be unique. But the good thing is that you do not have to override the Equals and gethashcode. Because the tuple does that internal.

    References:

    • HashSet Class
    • Tuple Class
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a simple templating solution for ruby, i.e. something that will
I'm looking for a straight forward css solution that will force labels to top
I'm looking for something like createdb in PostgreSQL or any other solution that would
Just looking for the first step basic solution here that keeps the honest people
I should clarify that I am looking for a client-side solution. Alternatively, is there
I' am supposed to write an application that lets you store data (contact informations)
I'm looking for a way to find bottleneck methods in a solution (lots of
I'm looking at building a simple web app that will expose an API that
I've been looking for solutions that provide a couple of types of protection and
I am currently looking at different ORM solutions for a project that is planned

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.