• 0

[VB.NET] Multiple Inheritance


Question

Hey gang,

I fully understand that VB.NET does not support multiple inheritance. So that said we are trying to figure a way to get a form of MI anyway. Attached is a simple diagram. In this you will see that sometimes we need the MS Collection Base class (first box) and we have our Base class (BLBase)

We have our own class (BLCollection) that needs to inherit from the MS CollectionBase. What we want is to have some objects that have our BLCollection and some objects that do not... (bottom two classes) however both classes at the bottom need to inherit from our BLBase class. The diagram shows that BLBase is inheriting from CollectionBase, and this will work for us in that we simply will not use the CollectionBase functions in "Object w/o Collection"

There must be a better way... I read a little about using multiple interfaces but I'm not getting how to impliment this.

EDIT:

Ramesees. Thanks, yes I know that the first diagram will work... but what I want is the 2nd diagram (newly added) so that the "Object w/o Collection" would not carry around the CollectionBase inhertance. Not a BIG deal... but it would be nice. (thanks again)

Thanks for any help.

post-45653-1178290842.gif

post-45653-1178292192.gif

Edited by jameswjrose
Link to comment
https://www.neowin.net/forum/topic/558305-vbnet-multiple-inheritance/
Share on other sites

3 answers to this question

Recommended Posts

  • 0

If I read that diagram correctly, if you set up your classes as they are described they will work the way you want

Here is some C# code (although the translation to VB.NET should not be difficult):

public class BLBase : CollectionBase
{

}

public class BLCollection : BLBase
{
		  //  By inheritance this will automatically inherit from CollectionBase
}

//  Now for the bottom classes

public class ObjWithoutCollection : BLBase
{

}

public class ObjWithCollection : BLCollection
{
	 //  This class will have all your specific collection code
	//   as well as the methods from BLBase and CollectionBase
}

I hope this helps :)

  • 0
  jameswjrose said:
Hey gang,

I fully understand that VB.NET does not support multiple inheritance. So that said we are trying to figure a way to get a form of MI anyway. Attached is a simple diagram. In this you will see that sometimes we need the MS Collection Base class (first box) and we have our Base class (BLBase)

We have our own class (BLCollection) that needs to inherit from the MS CollectionBase. What we want is to have some objects that have our BLCollection and some objects that do not... (bottom two classes) however both classes at the bottom need to inherit from our BLBase class. The diagram shows that BLBase is inheriting from CollectionBase, and this will work for us in that we simply will not use the CollectionBase functions in "Object w/o Collection"

There must be a better way... I read a little about using multiple interfaces but I'm not getting how to impliment this.

EDIT:

Ramesees. Thanks, yes I know that the first diagram will work... but what I want is the 2nd diagram (newly added) so that the "Object w/o Collection" would not carry around the CollectionBase inhertance. Not a BIG deal... but it would be nice. (thanks again)

Thanks for any help.

To utilize the interface method, you'd have to refactor BLCollection and have it implement IList, ICollection, and IEnumerable instead of inheriting CollectionBase, and have it inherit BLBase.

  • 0

Thank you very much. I'll give it a go first thing monday morn (hey, even geeks gota have a weekend, besides my wife just got out of the hospital, and hey, why dont you just cut me some slack.... I'll do it monday like I promised.... sheeeesh. Pushy guy)

<serious>

The model looks great, and I think I get it. Thank you very kindly. Great help.

</serious>

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I am using Waterfox Private Search now that I started using the Waterfox browser on my PC and Android. Both work great* search waterfox net with full stops in between. * I have an issue where making comments on articles on various websites is difficult with Waterfox on Android as it randomly adds spaces and doubles up on text.
    • I can't believe it was only two years since the last time MS raised their prices and now they think they can do it again so soon. Of course they needed to backtrack on this. I hope Nintendo is next.
    • I guess I gotta be even more specific then since I'm looking for an absolute confirmation.  The mini PC has never booted up or powered on by me. I'm assuming it'll be like buying a new PC from a store. Nothing is set up. Like absolutely nothing on the mini PC because I can't emphasize this enough. My USB drive already has Windows set up on it from my other desktop so I know it's clean. So now I connect it to the mini PC before it's even booted up or go to the desktop. I then turn on the mini PC and boot into the USB drive. I should see an existing partition. I'll delete it and then install Windows again over the entire drive. I don't necessarily want to create a separate partition. Once it installs and boots to the desktop, I'm assuming the drive is "clean" and free of any malware/viruses. Basically, this process will eliminate any potential for malware/viruses to still somehow hide in the SSD and then potentially affect me later.  I'm being very anal about this because I really don't trust anything bought from AliExpress, but the price was very tempting.  Is Windows Defender reliable? Afterwards, if I do a full scan and it doesn't find anything in the SSD and the USB drive, can I be confident the mini PC is now safe and secured to enter my banking credentials? If not, what else can I do to be absolutely certain?
    • I got an ESR Qi2 vent charger for my car and it's fantastic. It's very strong magnet and holds the phone securely over the worst potholes/roads, and my iPhone does charge. In Summer, the AC blows on the vent keeps and keeps the phone cold. In winter, I just close that vent, so it still stays cold. I agree with you on the Android front. Why not just build in the magnets like Apple does? It's frustrating to buy a case that adds magnets.
    • Hey, I've been using Windows since I was a little tyke. But for the last 15 years, I have been using Linux. I'm using EndeavourOS/Arch atm. wipe it, as in deleting anything from the SSD in the computer. Make a new partition. USB booting device should be free of malware, as long as you download it directly friom MS. Not some XYZ company.
  • Recent Achievements

    • Collaborator
      fernan99 earned a badge
      Collaborator
    • Collaborator
      MikeK13 earned a badge
      Collaborator
    • One Month Later
      Alexander 001 earned a badge
      One Month Later
    • One Month Later
      Antonio Barboza earned a badge
      One Month Later
    • Week One Done
      Antonio Barboza earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      581
    2. 2
      ATLien_0
      216
    3. 3
      Michael Scrip
      168
    4. 4
      Xenon
      136
    5. 5
      +FloatingFatMan
      125
  • Tell a friend

    Love Neowin? Tell a friend!