Advertisement Jump to content
Sign in to follow this  
Codorke

Error: cannot convert from 'std::string' to 'System::String __gc*' [C++]

This topic is 4900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is really getting to much for me !!! How can i do this conversion (see subject) ? I'm programming in Microsoft Visual Studio 2003 .NET Framework 1.1 (C++). maybe a lexical_cast< ... > but i dont know how. Can someone help me out please ? Thanks !!!!!!

Share this post


Link to post
Share on other sites
Advertisement
Even though I've never used .NET I'm gonna try. Try this:

std::string sSomeString;
System::string sSomeSlightlyDifferentString = System::String( sSomeString.c_str() );

If it doesn't work we need the help of someone using .NET.

Greetz,

Illco

Share this post


Link to post
Share on other sites
I'm using it like you said but now i getting the error :
System::String can only create a __gc on the __gc_heap


My Code :

System::String* unencodedString = System::String(text.c_str()); --> Error
Byte encodedBytes[] = ascii->GetBytes(unencodedString);
IEnumerator* myEnum = encodedBytes->GetEnumerator();
while (myEnum->MoveNext())
Byte b = *__try_cast<Byte __gc*>(myEnum->Current);

// Decode bytes back to String*.
System::String* decodedString = ascii->GetString(encodedBytes);

Share this post


Link to post
Share on other sites
If you're using managed C++ (which i suspect if you're using std::string) you will need to declare the System::String as __gc

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!