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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:52:23+00:00 2026-06-04T07:52:23+00:00

Consider the following . . . Dictionary<string, Dictionary<string, int>> myData; I would like to

  • 0

Consider the following . . .

Dictionary<string, Dictionary<string, int>> myData;

I would like to keep only the outer entries where the inner int > 1.

myData= myData.Select(c => c.Value.Where(i => i.Value > 1));

. . . throws a conversion error.

Thanks.

EDIT

The answer @Saeed gave is doing great, but however I now need something additional. I need the outer Dictionary to only contain entries where the inner Dictionary has more than 1 entry. (Every time I think I’ve got it, I don’t. And I’m sure it something I should be seeing!)

  • 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-04T07:52:24+00:00Added an answer on June 4, 2026 at 7:52 am

    You should cast it to dictionary, Also you can simply use anonymous type instead of its exact type.

    myData= myData
                 .Select(c => new {Key = c.Key,
                               Value = c.Value
                               .Where(i => i.Value > 1)
                               .ToDictionary(y=>y.Key, y=>y.Value)})
                 .ToDictionary(x=>x.Key, x=>x.Value);
    

    Update: After doing this, for your additional requirement do:

    myData = myData.Where(x=>x.Value.Count() > 1).ToDictionary(x=>x.Key,x=>x.Value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code: var myDict = new Dictionary<string, int>(); myDict.Add(Key1, 1); myDict.Add(Key2, 2);
Consider following program: static void Main (string[] args) { int i; uint ui; i
consider the following pgSQL statement: SELECT DISTINCT some_field FROM some_table WHERE some_field LIKE 'text%'
Consider the following code, where each key has an identical value: IDictionary<string, string> quarterbackDictionary
I would like to store insances of two classes in a dictionary structure and
I would like to store data in Generic Dictionary with keys that match over
Consider the following dictionary, d: d = {'a': 3, 'b': 2, 'c': 3, 'd':
Consider following example : public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam)
Consider following example. #include <iostream> #include <algorithm> #include <vector> #include <boost/bind.hpp> void func(int e,
Consider following: Partial View: <%= Html.ListBox(BlackList, Model.Select( x => new SelectListItem { Text =

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.