I’m pretty new to C++/CLI and I am trying to convert a System::String to a System::Char array.
Here’s what I have so far:
private: System::Void modeToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
Mode frmMode;
if(frmMode.ShowDialog() == System::Windows::Forms::DialogResult::OK){
array <Char>^ load [] = gcnew array<Char>(txtbxName->Text->ToCharArray());
}
}
txtbxName is a textbox inside a the form. Supposedly, this should work, but I get the compiler error:
error C2440: cannot convert from 'cli::array<Type> ^' to 'cli::array<Type> ^[]'
for the fourth line of the snippet.
ToCharArray is already giving you the array, you don’t need to create a new one. In addition, as the other answerer noted, you don’t need to specify
[]to create the array variable,array<>is sufficient.