Strongly typed C++ .NET dynamic vector/array/list

Posted on 2006-06-01
Last Modified: 2013-12-03
Hello Experts,

I'm trying to find the C++ .NET equivalent of vector<>, that I can use in a managed class.  If I try to make a vector<> member variable, it will not allow it in a managed class.

More specifically, I'm wanting to store arbitrary number of Strings, doubles, and also have a dynamic array of dynamic arrays of doubles.

I've discovered the "ArrayList" class, but that requires convoluted casting to and from .. due to it not being strongly typed.  Having been a C++ programmer for many years, this just feels wrong, and there has to be an easier way!  I still haven't even managed to figure out how to get doubles in and out of an ArrayList.

So, what is the "correct" .NET way to do this?

Question by:steveiam
    LVL 48

    Accepted Solution

    You can use .NET generics: see List<T> type and System.Collections.Generic Namespace. List<T> is strongly typed ArrayList.
    LVL 3

    Author Comment

    Ahh... Its in .NET 2.0.  I was initially using 1.1, which doesn't have it.


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now