Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7605575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:12:06+00:00 2026-05-31T00:12:06+00:00

For the problem I have these classes: Public MustInherit Class BaseLeaf(Of T) Implements IBaseLeaf

  • 0

For the problem I have these classes:

Public MustInherit Class BaseLeaf(Of T)
    Implements IBaseLeaf
    // etc

Public Class WebsiteLeaf
    Inherits BaseLeaf(Of Headline)
    // etc

Public Class WebsiteCollection
    Inherits BaseCollection(Of WebsiteLeaf)
    // etc

Public Class SubscriptionList
Private mCollection As BaseCollection(Of IBaseLeaf)

Public Sub LoadSubscriptions(ByVal collection As BaseCollection(Of IBaseLeaf))
    mCollection = collection
End Sub

In the Main class I am trying to call the following function:

Private Sub FetchSubscriptions(ByVal websites As WebsiteCollection)
        gUser.SubscriptionList.LoadSubscriptions(websites)
        // code
End Sub

This will access LoadSubscriptions with passing the “websites” variable.

As you can see LoadSubscriptions expects a BaseCollection(Of IBaseLeaf).

The “websites” variable is a WebsiteCollection, which is a BaseCollection(Of WebsiteLeaf(Of Headline)).

Now I am getting the error: Value of type ‘WebsiteCollection’ cannot be converted to ‘BaseCollection(Of IBaseLeaf)’.

What I am doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:12:08+00:00Added an answer on May 31, 2026 at 12:12 am

    If class B is a descendent of class A this does not mean that Collection(Of B) is a descendant of Collection(Of A)!

    If you have these definitions

    Dim stringList As List(Of String)
    
    Public Sub DoSomthingWithList(list As List(Of object))
         list.Add(Date.Now)
    End Sub
    

    and you could call the method like this

    DoSomthingWithList(stringList)
    

    then the method would try to add a Date to the list which is actually a list of strings! Since the parameter is typed as object the date would be boxed (i.e. converted to an object) but not converted to string.

    Therefore the collections List(Of X) and List(Of Y) are never compatible, even if Y inherits X.


    Let’s look at another example

    Public Class TestClass
        Implements IBaseLeaf      
        // etc
    

    What happens if you call LoadSubscriptions with a WebsiteCollection?

    Public Sub LoadSubscriptions(ByVal collection As BaseCollection(Of IBaseLeaf))      
        collection.Add(New TestClass())
    End Sub      
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with these simple classes: public class Thread { public string
I have a problem with these two classes: Creature: public abstract class Creature extends
I have these three classes: Command: package pack; public abstract class Command impements java.io.Serializable
suppose we have these classes: public class Record { int key; int value; Record(){
Suppose I have these two objects: public class Object1 { string prop1; string prop2;
Consider these two classes: public class A { B b; public A(B b) {
I have these 2 classes: @Entity @Table(name = S_MC_CC_CLIENTI) @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name=COD_TIPOCLIENTE) @DiscriminatorValue(PF) public class
So, I have a little problem here. Suppose I have: public class Repository<TEntity> where
Consider these classes: #include <iostream> #include <string> class A { std::string test; public: A
I have a class Employee and a class Building . These classes are not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.