title: How to call C# delegate to pass array of strings from native C simplest way?
body: <p>I know this can be done by mallocing in C, passing malloced pointer to delegate with parameter type IntPtr, marshalling to string[] and then freeing malloced memory with separate, exported C-function from managed code.</p>
  
  <p>My question is: Can this be done simpler way? E.g. : </p>
  
  <ul>
  <li>C# delegate parameter is of type string[]?</li>
  <li>no separate free function to call from managed code</li>
  </ul>
  
  <p>EDIT: I tried with delegate signature:</p>
  
  <pre><code>[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  MyManagedDelegate(string[] values, int valueCount)
  </code></pre>
  
  <p>and fucntion in C:</p>
  
  <pre><code>void NativeCallDelegate(char *pStringValues[], int nValues)
  {
      if (gSetStringValuesCB)
          gSetStringValuesCB(pStringValues, nValues);
  }
  </code></pre>
  
  <p>calling it in C:    </p>
  
  <pre><code>char *Values[]= {"One", "Two", "Three"};
  NativeCallDelegate(Values, 3);
  </code></pre>
  
  <p>This results in that i can use only 1st string in array.</p>