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

  • Home
  • SEARCH
  • 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 501335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:10:45+00:00 2026-05-13T06:10:45+00:00

I have a function which returns a List<Dictionary<string, object>> where object is a standard

  • 0

I have a function which returns a List<Dictionary<string, object>> where object is a standard type (string, int, etc).

I need to take a second List<Dictionary<string, object>> and ensure that All entries in list B are represented in List A (order in the list does not matter).

Currently I have code that looks like this:

foreach(Dictionary<string, object> rowResult in A) {
  foreach(Dictionary<string, object> rowCompare in B) {
    foreach(string columnName in rowResult.Keys) {
       // ... logic to compare columns
    }
  }

  // ...logic to compare rows so we dont find the same row twice.
}

Is there a more straightforward way to do this?

We dont care that all rows in rowResult are found, but all rows in rowCompare must be. It is ok to remove rows from the compare or result set to make the iteration easier.

My code works, it just looks over complicated and fragile.

  • 1 1 Answer
  • 1 View
  • 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-13T06:10:45+00:00Added an answer on May 13, 2026 at 6:10 am
    class DictionaryComparer<TKey, TValue> : IEqualityComparer<Dictionary<TKey, TValue>> {    
        public bool Equals(Dictionary<TKey, TValue> x, Dictionary<TKey, TValue> y) {
            if (x == null) {
                throw new ArgumentNullException("x");
            }
            if (y == null) {
                throw new ArgumentNullException("y");
            }
            if (x.Count != y.Count) {
                return false;
            }           
            foreach (var kvp in x) {
                TValue value;
                if(!y.TryGetValue(kvp.Key, out value)) {
                    return false;
                }
                if(!kvp.Value.Equals(value)) {
                    return false;
                }
            }
            return true;
        }
    
        public int GetHashCode(Dictionary<TKey, TValue> obj) {
            if (obj == null) {
                throw new ArgumentNullException("obj");
            }
            int hash = 0;
            foreach (var kvp in obj) {
                hash = hash ^ kvp.Key.GetHashCode() ^ kvp.Value.GetHashCode();
            }
            return hash;
        }
    }
    

    Then:

    public bool Contains(
        List<Dictionary<string, object>> first,
        List<Dictionary<string, object>> second) {
        if(first == null) {
            throw new ArgumentNullException("first");
        }
        if(second == null) {
            throw new ArgumentNullException("second");
        }
        IEqualityComparer<Dictionary<string, object>> comparer = new DictionaryComparer<string, object>();
        return second.All(y => first.Contains(y, comparer));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 273k
  • Answers 273k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to retain your ASIHTTPRequest. Because the request was… May 13, 2026 at 2:14 pm
  • Editorial Team
    Editorial Team added an answer FacesContext.getCurrentInstance() is null This will only happen when the current… May 13, 2026 at 2:14 pm
  • Editorial Team
    Editorial Team added an answer You have two problems in your code: you make userpointer… May 13, 2026 at 2:14 pm

Related Questions

Background Currently I have a C# Silverlight business application which uses RIA Services. The
I have created a BST full of WordInfo objects that have a vector to
It's a small thing, really: I have this function that converts dict objects to
I find myself very intrigued by the existence of a ConcurrentBag<T> class in the
I have a function which returns a list of property values from a collection:

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.