title: Write string to fixed-length byte array in C#
body: <p>somehow couldn't find this with a google search, but I feel like it has to be simple...I need to convert a string to a fixed-length byte array, e.g. write "asdf" to a <code>byte[20]</code> array. the data is being sent over the network to a c++ app that expects a fixed-length field, and it works fine if I use a <code>BinaryWriter</code> and write the characters one by one, and pad it by writing '\0' an appropriate number of times.</p>
  
  <p>is there a more appropriate way to do this?</p>