I have the following method in C++ which returns a long string object.
std::string GetBigString() {
// ...
}
I need to use this method in C# so I have to modify the method to return char*
. I have no idea about the length of the returned string - it can be short or very long. After the method is called I will like to have full memory control over the string in C# and not store it statically in the C++ memory space. (something like copy elision from C++ to C#)
Is there a good practice to achieve this?