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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:04:08+00:00 2026-05-17T20:04:08+00:00

I am parsing a file and I would like to store it in a

  • 0

I am parsing a file and I would like to store it in a lookup structure in a way that I can lookup with two keys.

I have a User Entity that has name, email and id, types are irrelevant.

I would like to store it in a Dictionary<User, id> so I can get the user id by looking up with User.

I also want the other way around, ie : Dictionary<Id, User>

I can create two structures and do the lookup. That s easy. I d like to do it with a single structure.

I am curious if I can do this with a single structure

I was thinking that I can do:

Dictionary<User, User> , then implement a IEqualityComparer<User>

Is there a better way to do this?

What would be the best practice to implement IEqualityComparer?

  • 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-17T20:04:08+00:00Added an answer on May 17, 2026 at 8:04 pm

    Whether you need to do this type of mapping or not, you can use a single dictionary to something like what you’re asking for. Here’s a rough sample:

    var dict = new Dictionary<string, object>();
    dict["ID_001"] = new User();
    dict["USER_??"] = 001; // Need a unique user string to replace the "??"
    

    Of course, you can make up any string you want. And if you want to wrap functions around things, you can avoid having to cast the object each time you get an item. (A static method might work better for you.)

    User GetUser(int id, Dictionary<string, object> dict) 
    {
        return (User)dict["ID_" + id];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey. I would like to upload a file and then parse it. Because parsing
I'm parsing a file that is set up like so: <blah-name name=Turkey> <blah-city name=Test/>
I'm parsing a CSV file that looks like this: E1,E2,E7,E8,,, E2,E1,E3,,,, E3,E2,E8,,, E4,E5,E8,E11,,, I
I've got these two structs that I need to store in files. I can't
I've got these two structs that I need to store in files. I can't
i have a blob url like blob:blahblah that points to a file. I want
I store my templates as files, and would like to have the opportunity to
I have student.xml file and am parsing this file using SAX Parser and now
I have developed a file parsing application on the android platform. How do I
Perl is really good for writing the kind of string/file parsing programs that I

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.