title: In C#, convert ulong[64] to byte[512] faster?
body: <p>I have a way that converts ulongs to bytes using binary shifts in a for statement but it's not very time efficient. Is there a way to cast a <code>ulong</code> array of size 64 directly into a byte array of size 512? This is a section of code that runs thousands of times and I need to save every millisecond so I can in turn save seconds.</p>
  
  <p>Edit:
  Right now this is what I'm doing:</p>
  
  <pre><code>                for (int k = 0; k &lt; ulongs.Length; k++) {
                      bytes[(k &lt;&lt; 3)] = (byte)(ulongs[k] &gt;&gt; 56);
                      bytes[(k &lt;&lt; 3) + 1] = (byte)(ulongs[k] &gt;&gt; 48);
                      bytes[(k &lt;&lt; 3) + 2] = (byte)(ulongs[k] &gt;&gt; 40);
                      bytes[(k &lt;&lt; 3) + 3] = (byte)(ulongs[k] &gt;&gt; 32);
                      bytes[(k &lt;&lt; 3) + 4] = (byte)(ulongs[k] &gt;&gt; 24);
                      bytes[(k &lt;&lt; 3) + 5] = (byte)(ulongs[k] &gt;&gt; 16);
                      bytes[(k &lt;&lt; 3) + 6] = (byte)(ulongs[k] &gt;&gt; 8);
                      bytes[(k &lt;&lt; 3) + 7] = (byte)(ulongs[k]);
                  }
  </code></pre>