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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:53:20+00:00 2026-05-10T19:53:20+00:00

Looking at System.Collections.Generic.Dictionary<TKey, TValue> , it clearly implements ICollection<KeyValuePair<TKey, TValue>> , but doesn’t have

  • 0

Looking at System.Collections.Generic.Dictionary<TKey, TValue>, it clearly implements ICollection<KeyValuePair<TKey, TValue>>, but doesn’t have the required ‘void Add(KeyValuePair<TKey, TValue> item)‘ function.

This can also be seen when trying to initialize a Dictionary like this:

private const Dictionary<string, int> PropertyIDs = new Dictionary<string, int>() {     new KeyValuePair<string,int>('muh', 2) }; 

which fails with

No overload for method ‘Add’ takes ‘1’ arguments

Why is that so?

  • 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. 2026-05-10T19:53:20+00:00Added an answer on May 10, 2026 at 7:53 pm

    The expected API is to add via the two argument Add(key,value) method (or the this[key] indexer); as such, it uses explicit interface implementation to provide the Add(KeyValuePair<,>) method.

    If you use the IDictionary<string, int> interface instead, you will have access to the missing method (since you can’t hide anything on an interface).

    Also, with the collection initializer, note that you can use the alternative syntax:

    Dictionary<string, int> PropertyIDs = new Dictionary<string, int> {   {'abc',1}, {'def',2}, {'ghi',3} } 

    which uses the Add(key,value) method.

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

Sidebar

Related Questions

Looking at the interface System.Collections.Generic.ICollection its definition requires that the inheriting member contains the
I have a static System.Collections.Generic.Dictionary<K, V> that's used as a cache. On a cache
I'm having a void in my Global.asax, looking like this using System; using System.Collections.Generic;
I'm looking content management system that would have features similar to stackoverflow: Users can
Im looking to have a login system on my asp.net mvc website and at
I am looking to get into operating system kernel development and figured and have
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; That's my namespaces. I
I was looking about some GDI tutorial but everything I have found so far
I'm working with a framework that uses collections derived from System.Collections.CollectionBase . Users have
I'm looking to test system responsiveness etc. on a few machines under certain CPU

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.