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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:41:33+00:00 2026-06-12T21:41:33+00:00

While attempting to implement my own Queue by wrapping the generic Queue, I noticed

  • 0

While attempting to implement my own Queue by wrapping the generic Queue, I noticed that Queue implements ICollection. However, the method signature of ICollection.CopyTo is as follows

void CopyTo(
    Array array,
    int index)

Whereas the method signature of the generic Queue.CopyTo is

public void CopyTo(
    T[] array, 
    int arrayIndex)

This is the same as the signature of the generic version of ICollection.CopyTo. My confusion comes from the fact that the generic queue doesn’t seem to implement the generic ICollection, but instead implements the standard ICollection. So what exactly is going on here?

  • 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-12T21:41:35+00:00Added an answer on June 12, 2026 at 9:41 pm

    As per the documentation:

    public class Queue<T> : IEnumerable<T>, ICollection, IEnumerable
    

    So it implements the generic IEnumerable<T> interface, but the non-generic ICollection interface.

    Don’t let the similarity of the names fool you – ICollection and ICollection<T> are entirely separate interfaces, and while something like this (implementing some generic interfaces but only non-generic other interfaces) is unusual, it’s entirely legitimate.

    I suspect that there were various aspects of ICollection<T> which the designers really didn’t want to support in Queue<T>, but equally they wanted to implement ICollection to allow folks to upgrade from the non-generic Queue class painlessly.

    EDIT: As noted in Dennis’s answer, ICollection.CopyTo is implemented explicitly in Queue<T>. This means that you can only get to that signature via an expression of type ICollection. For example:

    Queue<string> queue = new Queue<string>();
    Array array = new Button[10];
    queue.CopyTo(array, 0, queue.Count); // Compilation failure...
    ICollection collection = (ICollection) queue;
    collection.CopyTo(array, 0, queue.Count); // Compiles, but will go bang
    

    The method taking a strongly typed array would be valid to implement ICollection<T>.CopyTo, but the Add and Remove methods of ICollection<T> aren’t present – instead, you’re meant to Enqueue and Dequeue values.

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

Sidebar

Related Questions

I am attempting to implement an asynchronous method queue in Javascript as seen in
I am attempting to implement a method to draw a bunch of cubes using
I am attempting to implement xmpp chat/collaboration between two C# desktop clients that exchange
So I'm attempting to implement a hash table that will hash structures containing words.
I seem to be having some issues while attempting to implement logging into my
I'm attempting to modify a quicksort algorithm, and implement a pivot that is a
currently I'm attempting to basically implement and exact copy of Apples iMessage App. That
I have a web form that I am attempting to implement dynamic drop down
I'm attempting to implement a PHP method of authenticating a request to Associated Press
I'm attempting to implement a decorator on certain methods in a class so that

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.