Search code examples
.netc++-climanaged-c++

convert native c++ instance ( custom class ) to Object^ (system)


I have a native c++ class, lets say "probe". I need to add it to an arrayList. Add method of ArrayList is needed an Object^. So how can I convert it?


Solution

  • Don't use ArrayList.

    Don't use ArrayList for managed objects, prefer one of the generic collections instead, such as List<T>.

    Don't use ArrayList to hold native objects, instead use an STL container, such as std::vector.

    The only reason ArrayList even exists is for backward compatibility with code written in .NET 1.x.