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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:42:38+00:00 2026-06-05T03:42:38+00:00

Background: I’m trying to create my own Vector class to assist in performing mathematical

  • 0

Background: I’m trying to create my own “Vector” class to assist in performing mathematical calculations on groups of numbers. I am overloading the arithmetic operators ( + – * / ) to achieve the functionality that I want. At first, I used a private array in my class and then implemented the IEnumerable<T> interface. Afterwards, I thought of inheriting the List<T> class, but after reading a couple of articles, I understand that I should use Collection<T> instead. Please note that performance is very important when populating my “Vector” object with data.

Question: How does the Collection<T>.Add() method work? The List<T>.Add() documentation is very clear:

If Count already equals Capacity, the capacity of the List is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added.

However, the Collection<T>.Add() documentation says nothing at all about how it works. When I used List<T> as my base class I had access to the Capacity property and I was able to specify the size before using the Add() method. However, Collection<T> does not have a Capacity property—this is why I’m asking the question. Again, I reiterate: performance is very important.

Since performance is an issue, perhaps I should go back to using a private array and implementing the IEnumerable<T> interface. What do you think?

  • 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-05T03:42:40+00:00Added an answer on June 5, 2026 at 3:42 am

    A Collection<T> is a wrapper around IList<T>. The default constructor of Collection<T> just uses a new List<T>, so the Add behavior will be the same as List<T> assuming you use the default constructor.

    However, the Collection.Add() documentation says nothing at all about how it works

    That’s because the Add behavior is dependent on the underlying IList, which is passed in the constructor.

    However, Collection does not have a Capacity property

    Again, because that would depend on what the Collection is wrapping. It wraps the interface IList<T>. The interface has no notion of capacity. There could be an implementation of IList<T> that does not have a known capacity, like records in a database.

    If you need these implementation details such as capacity, then just use a List<T>. Collection<T> has no performance benefits over List<T> since it is using one anyway. If performance is critical to you then you may want to find a library that has already solved this problem, rather than rolling your own.

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

Sidebar

Related Questions

Background I am trying to create a copy of a business object I have
Background info I am trying to upgrade a custom CMS to support the HTML5
Background Hi All, I'm trying to use Boost::MPI, at the moment I'm just trying
Background I'm customising a tumblr theme (Source: hasaportfolio ), and I am trying to
Background: I am trying to add data to a SQL DB with C#. I
Background I have been asked by a client to create a picture of the
Background I have a Access 2010 database and want to create a pop-up progress
Background: I am a beginner javascript developer who is trying to understand and learn
Background: I'm trying to use a Google Map as an interface to mark out
Background : I'm trying to convert some JavaScript code which uses the the Crossfilter

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.