Hi, I'm trying to get back into programming and I'm using Visual Studio
2005 and I need some help. I've create a DataTable and want to use the
LoadDataRow method to add to the DataTable. I want to use this method
because it will check for a duplicate entry.
However, the LoadDataRow function requires an array of Object files and I can't seem to create one.
Object^ objectArray = gcnew Object[3];
But the compiler doesn't like it and gives a message saying:
"a native array cannot contain this managed type, Did you mean 'array<System::Object>"
Does anyone know how to solve this Thanks in advance

an array of Objects?
Sibusiso
cannot use * with Object try ^ instead.
cannot use a native array with this managed type
printerpro
array<System::Object> objectArray = gcnew Object[3];
and that gave me more errors. I tried several other combinations which was given by the compiler, each giving more errors. The error is just located on the line that this particular piece of code is on.
This is weird though because I use the MSDN as my first source of help when I come across a problem and this was the code that I found
Dominic99Rus
I'm curious what happened when you made a literal adaptation of the MSDN example (although I think I know):
Object* temp[ ] = new Object*[3];
I'm not working with the CLR, so this is not something I've had to sort out.
Scott Phibbs - MSFT
Did you try
array<System::Object> objectArray = gcnew Object[3];
to see if that actually works I think you just need to experiment (it could be the Object[3] that is being rejected, etc.) If you click on the error message, where does it take you in the source code line
Mostly, if you are building a pure managed code application, just be careful to use only C++/CLI concepts. It may take some study to get it all sorted out, and experimentation is probably the best teacher.
Also, did you try simply
Object^ objectArray[3];
with and without the reference indicator (^)
I don't know the answer, just suggesting some explorations.
Guillermo Proano MSFT
array<System::Object^> ^temp = gcnew array<System::Object^>(3);
I've really got to get used to this coding.