title: C# equivalent for ByteArrayOutputStream in java
body: <p>I have <code>java</code> code as</p>
  
  <pre><code>ByteArrayOutputStream baos = new ByteArrayOutputStream();
  baos.write(tokenBytes);
  baos.write(signedData);
  byte[] finalout = baos.toByteArray();
  </code></pre>
  
  <p>where tokenBytes and signedData are byte arrays.In <code>c#</code> I have written as</p>
  
  <pre><code> using (MemoryStream stream = new MemoryStream())
          {
              using (BinaryWriter writer = new BinaryWriter(stream))
              {
                  writer.Write(tokenBytes);
                  writer.Write(signature);
              }
              finalBytesToSend = stream.ToArray();
  
          }
  </code></pre>
  
  <p>where tokenBytes , signature  and finaleBytesToSend are byte arrays.</p>
  
  <p>Is it correct?  OR is there any other way to do it?</p>