title: Passing a char array from c# to c++ dll
body: <p>I have a dll of the LZ4 c implementation and I want to call the </p>
  
  <pre><code>LZ4_compress_default(const char* source,char* dest,int sourceLength,int maxdestLength);
  </code></pre>
  
  <p>function from a c# code. The function compresses the source array into the dest array. How to do this?</p>
  
  <p>My C# code:</p>
  
  <pre><code>DllImport(@"CXX.dll", CharSet = CharSet.Ansi, SetLastError = true, 
      CallingConvention = CallingConvention.Cdecl)] 
  internal static extern int LZ4_compress_default(
      [MarshalAs(UnmanagedType.LPArray)] char[] source, out byte[] dest, 
      int sourceSize, int maxDestSize); 
  
  
  byte[] result= new byte[maxSize]; 
  int x = LZ4_compress_default(array, out result, size, maxSize); 
  </code></pre>