title: How to know the type of deserialized class??(or objects)
body: <p>I have two classes</p>
  
  <pre><code>[Serializable]    
  public class Class1
  {                
      public List&lt;String[]&gt; items= new List&lt;string[]&gt;();        
  }
  
  [Serializable]
  public class Class2
  {
      public List&lt;String[]&gt; items = new List&lt;string[]&gt;();                
  }
  </code></pre>
  
  <p>and I serialize these classes and send data to clients like this</p>
  
  <pre><code>NetworkStream stream = client.GetStream();
  MemoryStream memory = new MemoryStream();
  BinaryFormatter bf = new BinaryFormatter();
  
  Class1 data = new Class1(); // or Class2
  data.items.Add(new String[]{"1", "2", "3"});       
  
  bf.Serialize(memory, data);
  memory.Position = 0;
  
  byte[] buffer = memory.ToArray();                        
  
  stream.Write(buffer, 0, buffer.Length);
  stream.Flush();
  </code></pre>
  
  <p>When Client program receive data from server, the program handle the data like this</p>
  
  <pre><code>BinaryFormatter bf = new BinaryFormatter();
  MemoryStream memory = new MemoryStream();
  NetworkStream stream = client.GetStream();
  
  int bufferSize = client.ReceiveBufferSize;
  byte[] buffer = new byte[bufferSize];
  int bytes = stream.Read(buffer, 0, buffer.Length);
  
  memory.Write(buffer, 0, buffer.Length);
  memory.Position = 0;
  </code></pre>
  
  <p>BUT in this situation, I don't know what is the type of data...Is Class1??? or Class2..</p>
  
  <p>How to know the type of deserialized class??(or objects)</p>