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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:18:12+00:00 2026-05-12T11:18:12+00:00

The MSDN explains Lookup like this: A Lookup<TKey, TElement> resembles a Dictionary<TKey, TValue> .

  • 0

The MSDN explains Lookup like this:

A Lookup<TKey, TElement>
resembles a Dictionary<TKey,
TValue>
. The difference is that a
Dictionary<TKey, TValue> maps keys to single values, whereas a
Lookup<TKey, TElement> maps keys to collections of values.

I don’t find that explanation particularly helpful. What is Lookup used for?

  • 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-12T11:18:13+00:00Added an answer on May 12, 2026 at 11:18 am

    It’s a cross between an IGrouping and a dictionary. It lets you group items together by a key, but then access them via that key in an efficient manner (rather than just iterating over them all, which is what GroupBy lets you do).

    For example, you could take a load of .NET types and build a lookup by namespace… then get to all the types in a particular namespace very easily:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Xml;
    
    public class Test
    {
        static void Main()
        {
            // Just types covering some different assemblies
            Type[] sampleTypes = new[] { typeof(List<>), typeof(string), 
                                         typeof(Enumerable), typeof(XmlReader) };
    
            // All the types in those assemblies
            IEnumerable<Type> allTypes = sampleTypes.Select(t => t.Assembly)
                                                   .SelectMany(a => a.GetTypes());
    
            // Grouped by namespace, but indexable
            ILookup<string, Type> lookup = allTypes.ToLookup(t => t.Namespace);
    
            foreach (Type type in lookup["System"])
            {
                Console.WriteLine("{0}: {1}", 
                                  type.FullName, type.Assembly.GetName().Name);
            }
        }
    }
    

    (I’d normally use var for most of these declarations, in normal code.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've found this MSDN article that explains how to monitor processes and services with
MSDN docs say that only value types need boxing, but this does not apply
MSDN says that you should use structs when you need lightweight objects. Are there
MSDN states that String.Intern retrieves the system's reference to the specified String and String.IsInterned
MSDN says that public static members of System.Windows.Application are thread safe. But when I
MSDN is a nice place to get vague, general information on this, with just
The MSDN documentation on WebBrowser Customization explains how to prevent new windows from being
I'm looking for an article or overview of WPF Panel types, that explains the
I have found here an interesting blog that explains how to secure the visibility
The MSDN does not provide, IMHO, a clear difference between Control.PointToScreen ( link )

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.