Reputation: 5805
How to return System::String handle from function?
Should I use gcnew or not? For example, which one of the two code examples below are correct?
System::String ^ManagedOptimizer::GetLogSolutionEvolution()
{
return gcnew System::String(myConstCharPointer);
}
or this one:
System::String ^ManagedOptimizer::GetLogSolutionEvolution()
{
return System::String(myConstCharPointer);
}
Thanks
Upvotes: 1
Views: 1908
Reputation: 3684
String
is a reference type , even if it is immutable. So you must use the "gcnew" version...
See also: String
Upvotes: 2