title: C# Passing a pointer of array to function starting at specific offset
body: <p>I'm porting a C++ application to C# and experiencing some issues with pointers.</p>
  
  <p>What I'm trying to achieve is to pass an array pointer with an offset so the passed function can work on the correct part of an array. I don't want to change the function's signature to add an extra value for the offset.</p>
  
  <p>So, this is an example piece of C++ code I would like to pass in C#:</p>
  
  <pre class="lang-c++ prettyprint-override"><code>void DoSomething( double p[] )
  {
      p[0] = 0.4;
      p[1] = 0.4;
  }
  
  int main()
  {
      double Vector[3];
  
      Vector[0] = 0.2;
      Vector[1] = 0.2;
      Vector[2] = 0.2;
  
      DoSomething( &amp;Vector[1] );
  }
  </code></pre>
  
  <p>How could I do that ? Keeping in mind that I can't pass the offset ?</p>
  
  <p><strong>[Edit]</strong>
  Thank you all for the answers.
  First, I have to apologize: I made a big mistake while copying the code.</p>
  
  <p>I wrote</p>
  
  <pre><code>DoSomething( Vector[1] );
  </code></pre>
  
  <p>on last line instead of</p>
  
  <pre><code>DoSomething( &amp;Vector[1] );
  </code></pre>
  
  <p>this has been corrected.</p>
  
  <p>I then realized that I was not very clear about the signature.</p>
  
  <ul>
  <li><p>I can slightly change the signature of the function, but I can't add any arguments</p></li>
  <li><p>I am already using the "unsafe" and "fixed" keywords, so it won't hurt me</p></li>
  <li><p>It doesn't need to be efficient code since this porting is intended to be a Quick &amp; Dirty implementation of an algorithm written by somebody else for a prototype project. If the project is a "Ok go", the code would be thrown at garbage and rewritten in a C++ dll.</p></li>
  <li><p>The function "DoSomething" is actually a nest of a few other functions, it is designed as a fast math work but sadly, I don't have all the knowledge about to code it myself. That's why I assume the author has nicely designed its function since it's used world-wide.</p></li>
  </ul>
  
  <p>I'll try with Servy's suggestion and come back to you in a few days when I'll get back.</p>