title: Is it possible to have one big array, and then smaller ones which point to subsections of the larger array, in C#?
body: <p>I would like to have an array that holds all of my class' parameters in a single array, and then have each of those parameters point to their locations in the large array.</p>
  
  <p>The reason i want to do this is because i'm going to be optimizing a functio nthat's based on said parameters, but the minimization requires all the parameters be inside a single array - i don't want to be copying this array back and forth at every step - i'd rather have the individual parameters point to their locations in the main array. Something like this:</p>
  
  <pre><code>class myClass{
    int nVariables;
    public double[] parameters; //length = X * nVarialbes
    public double[] A; //length = X
    public double[] B; //length = X
    public double[] C; //length = X
  }
  </code></pre>
  
  <p>where <code>parameters</code> is really something like <code>[a1,a2,a3,b1,b2,b3,c1,c2,c3]</code> (where <code>X==3</code> in this example) - the number of each parameter is the same here, but i would rather a solution that would allow that to be generic.</p>
  
  <p>This will also allow me to change the elements of <code>A</code>, <code>B</code>, and <code>C</code> and have the array holding them all update too.</p>
  
  <p>I need to have the array holding all the data as a single contiguous array for the optimization, so just doing <code>parameters = new double[]{A,B,C};</code> won't work - unless there's a way i can then access that as if it were a single array; my understanding was that a jagged array was not contiguous in memory though, and i'm not familiar enough with rectangular arrays to do what i want here.</p>