0
votes

I have a listBox in Visual C++ 2008, and I want the first line convert to string. So first, I select the first line

listBox1->SetSelected( 0, true );

And afterwards, I want to convert it to string

string t = listBox1->SelectedItems[ 0 ];

Which results in an error:

error C2440: 'initializing' : cannot convert from 'System::Object ^' to 'std::basic_string<_Elem,_Traits,_Ax>'

How can I convert it?

1

1 Answers

1
votes

Definitely look into using the marshal_as template method. It handles all the nasty conversions for you internally.