title: Serialization byte array vs XML file
body: <p>I am heavily using byte array to transfer objects, primitive data, over the network and back. I adapt java's approach, by having a type implement ISerializable,  which contains two methods, as part of the interface, ReadObjectData and WriteObjectData. Any class using this interface, would write date into the byte array. Something Like that</p>
  
  <pre><code>  class SerializationType:ISerializable
      {
         void ReadObjectData (/*Type that manages the write/reads into the byte array*/){}
         void WriteObjectData(/*Type that manages the write/reads into the byte array*/){}  
      }
  </code></pre>
  
  <p>After write is complete for all object, I send an array of the network.</p>
  
  <hr>
  
  <p>This is actually two-fold question. Is it a right way to send data over the network for the most efficiency (in terms of speed, size)?</p>
  
  <p>Would you use this approach to write objects into the file, as opposed to use typically xml serialization?</p>
  
  <p><strong>Edit #1</strong></p>
  
  <p><em>Joel Coehoorn</em> mentioned BinaryFormatter. I have never used this class. Would you elaborate, provide good example, references, recommendations, current practices -- in addition to what I currently see on msdn?</p>