I have a superclass NetworkTest and 3 derived classes PingTest, Pop3Test, SMTPTest. I want to create a big list of all the tests, like this:

Dim Tests As New List(Of NetworkTest)

        Dim PingTests As List(Of PingTest) = ReadPingTestsFromFile(PingFile)
        Tests.AddRange(PingTests)

        Dim Pop3TestResults As List(Of Pop3Test) = ReadPOP3TestsFromFile(POP3File)
        Tests.AddRange(Pop3TestResults)

        Dim SMPTTests As List(Of SMTPTest) = ReadSMTPTestsFromFile(SMTPFile)
        Tests.AddRange(SMPTTests)

In c++ you can make a vector of pointers of type NetworkTest and then it will let you use all of the function defined for the particular type of subclass that is in a position in the vector. Is there a similar concept in vb.net?

Thanks,

Dave

Recommended Answers

All 2 Replies

Yes you can. (MustInherit, MustOverride - virtual)

hm I don't see how inheritance shows me how to make a List(of abstractClass) and fill it with DerivedClass and then use DerivedClass operatons?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.