I am working in Visual C++. I'm giving following command
String nodename[100];
but this command is giving the following error
"error : 'System::String' : a native array cannot contain this managed type"
So what should I do now ?
I am working in Visual C++. I'm giving following command
String nodename[100];
but this command is giving the following error
"error : 'System::String' : a native array cannot contain this managed type"
So what should I do now ?
If you want to write a native C++ application, then you can't, as the error says, use managed types.
That means you have to use the C++ string class,
#include <string> // at the top of the file
std::string nodename[100]; // where you want to declare the array
instead of System::String
.
On the other hand, if you want to make a managed C++/CLI application, then you can't use native arrays. (But can use all the .NET types)
You didn't say whether you want Managed C++, C++/CLI, or unmanaged C++
managed C++
http://www.codeproject.com/KB/mcpp/csarrays01.aspx
C++/CLI
http://www.codeproject.com/KB/mcpp/cppcliarrays.aspx
unmanaged C++ (standard C++)
std::string nodename[100]; // uses STL string, not .NET String
OK. First off it looks like you are using managed C++ (ick). Secondly, you are trying to declare an array of strings (not chars, but entire strings). Is that really what you want to do? Are you sure you don't want something like char nodename[100]
or just String nodename
?
If you really want an array of strings, it looks like the compiler either wants you to use one of its managed vector-like types to do it, or to use only unmanaged types to do it.