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 byte[20]
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 BinaryWriter
and write the characters one by one, and pad it by writing '\0' an appropriate number of times.
is there a more appropriate way to do this?