title: Different types in an array, how to know what to cast them to when taking them out of array?
body: <p>Assume a generic <strong>List</strong> of type <strong>Packet</strong>, holding custom classes extending <strong>Packet</strong>, such as <strong>LoginPacket</strong> or <strong>ChatPacket</strong>.</p>
  
  <p>Let's say I put these in a list. When I take them out, the most 'specific' type each will be is <strong>Packet</strong>. I want to cast these into their more specific types though, back into their original <strong>LoginPacket</strong> or <strong>ChatPacket</strong> or back into whatever their original types were.</p>
  
  <p>Question: How can I do this?</p>
  
  <p>Reference: <a href="https://stackoverflow.com/questions/1829605/how-to-cast-an-object-programmatically-at-runtime">How to cast an object programmatically at runtime?</a></p>
  
  <p>So...it seems like if these custom classes share a common interface, it would solve the casting problem? But if so, my classes can't all share one interface. I need to build interfaces upon interfaces and classes upon classes. So...how would I do this? Sorry if this question isn't so accurate. Not sure how to articulate my exact issue.</p>