title: how to serialize several objects in one file in C# with protobuf
body: <p>I have the class <code>Person</code>, and I want to have several instances of it, and I want to serialize these in one file. How can I do it?
  I mustn't create a list of <code>Person</code> then serialize this.
  I want can to deserialize one instance of class that save (for example fourth instance that saved). how can I do it?</p>
  
  <p>Person Class :</p>
  
  <pre><code>[ProtoContract]
  class Person
  {
      public Person()
      { }
      [ProtoMember(1)]
      public int a;
      public Person(int d)
      {
          a = d;
      }
  }
  </code></pre>
  
  <p>method to serialize:</p>
  
  <pre><code>public void serialize()
      { 
          Person p1 = new Person(1);
          Person p2 = new Person(2);
          Person p3 = new Person(3);
          Person p4 = new Person(4);
          Person p5 = new Person(5);
          FileStream file = File.Create("person.bin") ;
          Serializer.Serialize(file, p1);
          Serializer.Serialize(file, p2);
          Serializer.Serialize(file, p3);
          Serializer.Serialize(file, p4);
          Serializer.Serialize(file, p5);
          file.Close();
      }
  </code></pre>
  
  <p>method to deserialze :</p>
  
  <pre><code>public void deserialize()
      {
          Person nP1, nP2,nP3,nP4,nP5;
          FileStream file = File.OpenRead("person.bin");
          nP1 = Serializer.Deserialize&lt;Person&gt;(file);
          nP2 = Serializer.Deserialize&lt;Person&gt;(file);
          nP3 = Serializer.Deserialize&lt;Person&gt;(file);
          nP4 = Serializer.Deserialize&lt;Person&gt;(file);
          nP5 = Serializer.Deserialize&lt;Person&gt;(file);
          file.Close();
      }
  </code></pre>