Marshal array of struct from c++ dll to c#
<p>I want to return array of struct from the C++ dll to c#. I am trying it as following:</p>

<p>In c++ code:</p>

<pre><code> Vertex*
GetVertices(Vertex* vertices, float aPos, int&amp; vSize) {
     if ( !plane ) {
        plane = new ClipPlane;
        plane-&gt;type = PlaneType;
    }
     Vertex* v = plane-&gt;mesh-&gt;vertex;
     vSize = plane-&gt;mesh-&gt;size*3;
     vertices = v;

     return vertices;
}
</code></pre>

<p>and exported it in c++ like <code>Some_API Vertex* GetVertices(Vertex*, float, int &amp;);</code></p>

<p>and on C# side:</p>

<pre><code>[DllImport("some.dll", CallingConvention = CallingConvention.Winapi)]
        public static extern IntPtr GetVertices(Vertex[] vertices, float aPos, ref int vSize);
</code></pre>

<p>and calling it like:</p>

<pre><code>GetMeshSize(x_value, ref vSize);
            Vertex[] vertices = new Vertex[vSize];
            GetVertices(vertices, x_value, ref vSize);
</code></pre>

<p>Forget about the vSize and x_value for time being. My problem is I am not able to get the values of vertices in c#, I just want to know that how do I marshal array of the struct Vertex in c#. Note that I dont know anything about Marshal.</p>
