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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:31:17+00:00 2026-06-12T18:31:17+00:00

I have a interface that can implement various collections and data types, it works

  • 0

I have a interface that can implement various collections and data types, it works fine with some collection but the dictionary is giving me issues, I’m guessing because the Dictionary is a little different and has key value pairs?

public interface IStructure
{
    void InsertRun<T> (T item);
    ICollection RetrieveSortedListRun<T>();
    T RetrieveItemRun<T>(T item);
}

class DictionaryRun : IStructure
{
    IDictionary<int, object> dictionary;

    public DictionaryRun()
    {
        dictionary = new Dictionary<int, object>();
    }

    public void InsertRun<T>(T item)
    {
        dictionary.Add(dictionary.Count + 1, item);
    }

    public ICollection RetrieveSortedListRun<T>()
    {
        return dictionary;
    }

    public T RetrieveItemRun<T>(T item)
    {
        return item;
    }
}
  • 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-12T18:31:19+00:00Added an answer on June 12, 2026 at 6:31 pm

    IDictionary<TKey, TValue> does not implement ICollection, it implements ICollection<KeyValuePair<TKey, TValue>>.

    As is, if you changed your dictionary to be a IDictionary your code would compile.

    However, it seems to me that your overall design of the interface and the object could be reworked.

    public interface IStructure<T>
    {
      void InsertRun(T item);
      ICollection<T> RetrieveSortedListRun();
      T RetrieveItemRun(T item);
    }
    
    
    class DictionaryRun<T> : IStructure<T>
    {
      IDictionary<int, T> dictionary;
    
      public DictionaryRun()
      {
        dictionary = new Dictionary<int, T>();
      }
    
      public void InsertRun(T item)
      {
        dictionary.Add(dictionary.Count + 1, item);
      }
    
      public ICollection<T> RetrieveSortedListRun()
      {
        return dictionary.Values;
      }
    
      public T RetrieveItemRun(T item)
      {
        return item;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that you can't have a constructor in an interface, but here is
I want to implement an aplication where I have various Objects that can be
I saw DatabaseErrorHandler interface that have onCorruption method , this interface can be passed
As you know, OAuth can support RSA-SHA1 Signature. I have an OAuthSignature interface that
I am learning Java and just found that the Interface can have fields, which
HI, I have a device that exposes a telnet interface which you can log
What is the best way to implement an interface that combines some instances of
I have a thread that calls various APIs of a COM interface. Now I
Hi I have the following interfaces that I need to create. Can you just
I have read that in Java interfaces can't be instantiated ( in the documentation,

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.