Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your <code>arrayRow[]</code> and <code>arrayCol[]</code> will be just two lines of a two-dimensional array (if you didn't mean jagged one).</p> <p>So the code to unite two arrays into one is just:</p> <pre><code>public static T[,] Union&lt;T&gt;(T[] first, T[] second) //where T : struct { T[,] result = new T[2, Math.Max(first.Length, second.Length)]; int firstArrayLength = first.Length * Marshal.SizeOf(typeof(T)); Buffer.BlockCopy(first, 0, result, 0, firstArrayLength); Buffer.BlockCopy(second, 0, result, firstArrayLength, second.Length * Marshal.SizeOf(typeof(T))); return result; } </code></pre> <p>Which will produce this result: <a href="http://pasteboard.co/1eEsHzOi.png" rel="nofollow">image</a>.</p> <p>As <a href="http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/5d525b76-f5b6-4340-a899-c3c82570d2e1#4fd0199f-ca1a-40be-90b0-c5c31208e105" rel="nofollow">it have been mentinoned</a>, <code>BlockCopy</code> is cooler than <code>for</code> cycle.</p> <hr> <p>If you <strong>do</strong> mean that you need a jagged array (like <code>int[][]</code>), that the solutiona will be way more simplier:</p> <pre><code>public static T[][] UnionJagged&lt;T&gt;(T[] first, T[] second) { return new T[2][] { first, second }; } </code></pre> <p>Which transforms into even simplier if we add multiple-array-as-parameters functionality:</p> <pre><code>public static T[][] UnionJagged&lt;T&gt;(params T[][] arrays) { return arrays; } static void Main() { int[] a = new int[] { 10, 2, 3 }; int[] b = new int[] { -1, 2, -3 }; int[] c = new int[] { 1, -2, 3 }; int[][] jaggedThing = UnionJagged(a, b, c); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload