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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:17:27+00:00 2026-05-26T02:17:27+00:00

I am having a dictionary which was defined as follows Dictionary<int, List<int>> dict1 =

  • 0

I am having a dictionary which was defined as follows

Dictionary<int, List<int>> dict1 = new Dictionary<int, List<int>>();

I will have a list element where i can store the values which will come from database

List<int> lstdbTaskID = new List<int>();

assume this holds

100 105 110 200

respectively.

I will have my dictionary with values stored as follows. Assume that i have 2 keys 10,20 respectively, and for this key values i will have my values as for 10 i will have 100,105 and 110 and for 20 i will have 200.

I would like to compare these values with the list available lstdbTaskID

I tried this

foreach (int strlst in lstdbTaskID)
{
    if (dict1.ContainsValue(lstdbTaskID[strlst]))
}

But i am getting errors as follows

The best overloaded method match for ‘System.Collections.Generic.Dictionary>.ContainsValue(System.Collections.Generic.List)’ has some invalid arguments`

and

Cannot convert from ‘int’ to ‘System.Collections.Generic.List’`

can any help me on this?

  • 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-26T02:17:27+00:00Added an answer on May 26, 2026 at 2:17 am

    Your code is wrong at because you are trying to compare int value with List of int.

    Your dictionary is:
    Dictionary of int to List of int.

    and you have another structure as
    List of int

    so when you do:

    // Compiler fails here because you are trying to check whether dictionary contains
    // the given integer value. Dictionary in this case has a list of integers as its `Value` 
    // in its `<Key,Value>` pair.
    dict1.ContainsValue(lstdbTaskID[strlst])
    

    Use linq statement:

    foreach (int strlst in lstdbTaskID)
    {
        if (dict1.Any(pair => pair.Value.Contains(strlst)))
        {
            // do something
        }
    }
    

    Edit: If you want this without linq, do the linq task by self.

    foreach (int strlst in lstdbTaskID)
    {
        foreach (int key in dict1.Keys)
        {
            if (dict1[key].Contains(strlst))
            {
                // do something
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dictionary/list balance_sign_dict from which I need to retrieve 2 values based
My dictionary will consist of several thousand keys which each key having a 1000x1000
How to get unique values based on dictionary key, which is an element of
How to convert Dictioanry<String,List<String>> into Dictionary<String,String> i'm having a dictionary like Dictioanry<String,List<String>>dictOne=new Dictionary<String,List<String>>(); and
I have a dictionary with embedded objects, which looks something like this: notes =
I'm having a spot of trouble with generics in C#. I have to store
I have created a list of dictionary in a format as below: [{u'PLAN_A': True,
In my application I am having a dictionary which contains Keys A-Z ie 26
Say I have a Dictionary object which contains many instances of an object called
I am having a dictionary like as dict1 = { 0 : 0, 1

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.