"Mutation of Marshalled Strings (CPP Side)"

// C++
 
extern "C" __declspec(dllexport) void StringMutationExample(INTEROP_STRING myString) {
    const_cast<char16_t>(myString)[0] = L'R';
}


Code snippet taken from "P/Invoke Tips".