title: can native C **char be safely passed to managed C# delegate with paramter type "out string"?
body: <p>In C:</p>
  
  <pre><code>extern "C" __declspec(dllexport) int CfgGetVariableString(const char *Name, char **Value)
  {
      char StrValue[STR_MAX];
      int RetValue = GetVariableToStrValue(Name, StrValue, STR_MAX);
      if (RetValue == 0)
          *Value = StrValue;
  
      return RetValue;
  }
  </code></pre>
  
  <p>C# </p>
  
  <pre><code>[DllImport(DllName, CallingConvention = DllCallingConvention)]        
  private static extern int CfgGetVariableString([MarshalAs(UnmanagedType.LPStr)]string name, [MarshalAs(UnmanagedType.LPStr)]out string value);
  </code></pre>
  
  <p>This does not work. I can make it work by calling CoTaskMemAlloc, but then I guess I should free it with separate managed to native call?</p>
  
  <p>So what is the cleanest way to do it?</p>