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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:23:47+00:00 2026-05-23T11:23:47+00:00

I have the following dictionary: Dictionary<int, string> selectedDrivers = new Dictionary<int, string>() { {

  • 0

I have the following dictionary:

Dictionary<int, string> selectedDrivers = new Dictionary<int, string>()
{
    { 1, "Michael Schumacher" },
    { 2, "Michael Schumacher" },
    { 3, "Jensen Button" }
};

What I try to achieve is a linq query that will find the duplicates, retrieve the name only once, along with the positions this duplicate has. So, for example, the above would result in "Michael Schumacher" 1 2. I would like the result to go into a Dictionary<string, List<int>>.

Getting excited fast, this little nugget I wrote seems to be going in the right direction, except that I have Michael Schumacher twice. And it’s not yet in a Dictionary<string, List<int>>

var a = selectedDrivers.GroupBy(a => a.Value).
        Where(b => b.Count() > 1);
  • 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-23T11:23:48+00:00Added an answer on May 23, 2026 at 11:23 am
    var a = selectedDrivers.GroupBy(a=>a.Value)
                .Where(g=>g.Count() > 1)
                .ToDictionary(g => g.Key, g => g.Select(a=>a.Key).ToList());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following List : List<Dictionary<int, Dictionary<string, string>>> lngList lngList.Add(new Dictionary<int,Dictionary<string,string>>().Add(1,new Dictionary<string,string>().Add(Item1Key,Item1Value))); lngList.Add(new
I have the following dictionary: Dictionary<int,string> dic = new Dictionary<int,string>(); dic[1] = "A"; dic[2]
I have the following nested dictionaries: Dictionary<int, Dictionary<string, object>> x; Dictionary<int, SortedDictionary<long, Dictionary<string, object>>>
I have the following decleration: private Dictionary<string, Dictionary<string, File>> listFiles = new Dictionary<string,Dictionary<string,File>>(); How
I have the following custom property in my code: public Dictionary<int, string> ServiceIdList {
I am using EF 4 and have the following code. public static Dictionary<Tuple<int, string>,
I have a base class that has the following property: public virtual Dictionary<String, int>
I have a class that contains the following property: public Dictionary<string, int> CommentCounts {
I have this structure: static Dictionary<int, Dictionary<int, string>> tasks = new Dictionary<int, Dictionary<int, string>>();
I have a method with the following signature: public ActionResult RenderFamilyTree(string name, Dictionary<string, string>

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.