title: Equivalent C code in C#. (uint8_t *) cast?
body: <p>I am trying to convert these C piece of code into C#. But I've stumble in some parts that I don't understand exactly what is happening, so I am unable to translate it.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>void foo(uint64_t *output, uint64_t *input, uint32_t Length){
  
      uint64_t st[25];
  
      memcpy(st, input, Length);
  
      ((uint8_t *)st)[Length] = 0x01;
  
      memset(((uint8_t *)st) + Length + 1, 0x00, 128 - Length - 1);
  
      for(int i = 16; i &lt; 25; ++i) st[i] = 0x00UL;
  
      // Last bit of padding
      st[16] = 0x8000000000000000UL;
  
      bar(st);
  
      memcpy(output, st, 200);
  }
  </code></pre>
  
  <p>More specifically in the <code>((uint8_t *)st)[Length] = 0x01;</code> part. I cannot understand the cast/pointer in this line. Why is the <code>*</code> there for? If somebody could explain what is happening, I would be grateful.</p>
  
  <p>What I got so far in C#:</p>
  
  <pre class="lang-cs prettyprint-override"><code>private void foo(ref ulong[] output, ref ulong[] input, uint Length)
      {
          ulong[] st = new ulong[25];
  
          //memcpy(st, input, Length);
          Buffer.BlockCopy(input, 0, st, 0, (int)Length);
  
          // Help in these line please:
          //((uint8_t *)st)[Length] = 0x01;
  
          // Still don't know what to do here too:
          //memset(((byte)st) + Length + 1, 0x00, 128 - Length - 1);
  
          for (int i = 16; i &lt; 25; ++i)
          {
              st[i] = 0x00U;
          }
  
          // Last bit of padding
          st[16] = 0x8000000000000000U;
  
          bar(st);
  
          //memcpy(output, st, 200);
          Buffer.BlockCopy(st, 0, output, 0, 200);
      }
  </code></pre>
  
  <p>Thank you.</p>