title: VB.NET List(Of T) - Can I use it to hold items of several types?
body: <p>Assuming a base type of "Message"...</p>
  
  <pre><code>Public Class Message
     Public ID As Int64
     Public Text As String
     Public MessageType as String
  End Class
  </code></pre>
  
  <p>...and then two derived classes...</p>
  
  <pre><code>Public Class PhoneMessage
     Inherits Message
     Public MessageLength As Int64
  End Class
  
  Public Class MailMessage
     Inherits Message
     Public Postage As Int64
  End Class
  </code></pre>
  
  <p>I would like to have one collection of Message objects which can be either PhoneMessages or MailMessages, so that I can iterate through the list and deal with each message based on what type it happens to be.</p>
  
  <p>Attempting just to use .Add() fails, saying that I can't add an item of type PhoneMessage to a List(Of Message).  Is there some elegant way to accomplish what I'm trying to do?  I had thought I could accomplish this with generics, but I think there's a gap in my understanding.  If it can be accomplished in .NET 2.0, that would be ideal.</p>
  
  <p>Thank you in advance.</p>