title: Are P/Invoke [In, Out] attributes optional for marshaling arrays?
body: <p>Assume that there is a native function with a pure-C interface like the following one, exported from a native DLL:</p>
  
  <pre><code>// NativeDll.cpp
  
  extern "C" void __stdcall FillArray(
      int fillValue, 
      int count, 
      int* data)
  {
      // Assume parameters are OK...
  
      // Fill the array
      for (int i = 0; i &lt; count; i++)
      {
          data[i] = fillValue;
      }
  }
  </code></pre>
  
  <p>The following P/Invoke works fine (tested with VS2010 SP1):</p>
  
  <pre><code>[DllImport("NativeDll.dll", CallingConvention=CallingConvention.StdCall)]
  public static extern void FillArray(
      int fillValue,
      int count,
      [In, Out] int[] data
  );
  </code></pre>
  
  <p>as well as this P/Invoke, same as above, but <em>without</em> the <strong><code>[In, Out]</code> attributes</strong>:</p>
  
  <pre><code>[DllImport("NativeDll.dll", CallingConvention=CallingConvention.StdCall)]
  public static extern void FillArray(
      int fillValue,
      int count,
      int[] data
  );
  </code></pre>
  
  <p>So, are those <code>[In, Out]</code> attributes <strong>optional</strong> for marshaling arrays?
  What is their purpose, if any?
  Is it OK to omit them in our P/Invoke declarations?</p>