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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:47:38+00:00 2026-06-10T07:47:38+00:00

I came across the following code: var collection = new Collection<string>(); I haven’t seen

  • 0

I came across the following code:

var collection = new Collection<string>();

I haven’t seen the Collection class used too much, and can’t find too much information about its purpose. Looking at the .NET Framework source, it’s pretty much just a wrapper around a List as it stores a List member field. Its constructor is as follows:

public Collection()
{
  this.items = (IList<T>) new List<T>();
}

And it also implements IList. So you can declare the Collection as:

IList<string> collection = new Collection<string>();

Which to me is functionally equivalent to creating a List instead:

IList<string> collection = new List<string>();

So when would you ever want to use it over a List in your own code? I see that it is a base class for other .NET collections, but why would they include this as a public concrete (as opposed to internal and/or abstract)?


Regarding comments around possible duplicates — the answers to related questions seem to say that Collection class is supposed to be used as a base class. What I’m really asking that’s different is:

  1. If using in your own code, why not use List as a base class instead?
  2. Does it really ever make sense to instantiate a new Collection in
    your own code in place of List?
  3. If it really is only provided to serve as a base class, why is it not abstract?
  • 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-10T07:47:39+00:00Added an answer on June 10, 2026 at 7:47 am

    I don’t really like answering my own questions, but as far as Q3 is concerned I believe I understand the reasoning. I got it while looking at this link referenced in Bas Paap’s answer.

    In short, the reason the Collection class is not abstract is because you may want to leave yourself the option of deriving from the class at a later date. In the meantime, you can use it as a return type and instantiate it directly. The link shows a code example where this is the case.

    I’ve upvoted all other answers that I thought addressed the issues raised in the question.

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

Sidebar

Related Questions

I am reading this blog and came across following code RunAgain = Class.new(Exception) def
I just came across the following code: for(Iterator<String> iterator = stuff.iterator(); iterator.hasNext();) { ...
I was looking at the following code I came across for printing a string
I recently came across the following line of code: var type = (typeof x).toLowerCase();
I came across the following code: var f = function () { var args
I came across the following code and was wondering what the IMG.active refers too.
I came across the following code snippet on the Scala mailing list: scala> class
Looking through some code I came across the following code trTuDocPackTypdBd.update(TrTuDocPackTypeDto.class.cast(packDto)); and I'd like
I am learning javascript and I came across the following code snippet: var outerValue
I came across following code function currentSlideFromParams() { var result; if (result = window.location.hash.match(/#([0-9]+)/))

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.