• 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

    • No I don't also get my news for one source. Have you considered that maybe I just don't care about tech enough to spend time reading multiple sources? Anyway my website preferences are way off topic.
    • The bloat on windows after 7 was acceptable, but 11 its even worse than chinese android phone makers, because at least they can remove the ads or apps, but w11 shove you bloat with no option to remove it, it seems that 25h2 will fix that
    • When I say I don't see the appeal, I meant as in general, of the character within the story. I guess apart from being a foil, as mentioned, but I still feel it could probably be done a bit more...less on the nose? A bit more nuanced? Something like that. He really just felt more like a chance to cast Fillion more than anything (to me, anyway). Obviously I am aware that Guy Gardner is not exactly meant to be an *appealing* character
    • This excellent 27-inch 1440p 240Hz QD-OLED gaming monitor is way under $500 by Sayan Sen If you are on the hunt for a great gaming monitor that is under $500, then AOC has a great option today that is worth considering. The model in question is the AOC Q27G4ZD which is a 27-inch 240 Hz display based on QD-OLED (Quantum Dot OLED) and it is at just $428 making it lowest ever priced (purchase link under the specs table below). The specialty of QD-OLED is that pairs the self-emissive OLED pixels with a layer of quantum dots, converting blue OLED light into pure red and green wavelengths more efficiently than traditional color filters. The result is brighter highlights, wider color gamut, and higher color volume without sacrificing OLED’s infinite contrast and instant response. Quantum dots are also said to reduce energy loss in color conversion, while boosting luminance and vibrancy. Thanks to the excellent color reproduction alongside the contrast, this QD-OLED monitor can be used for professional photo/video editing, animations, and such as well, plus working on spreadsheets and other office docs should be a breeze too. The technical specifications of the AOC Q27G4ZD are given below: Specification Details Diagonal Screen Size 26.5 " (67.3 cm) Panel Technology Quantum Dot OLED (QD-OLED) Maximum Refresh Rate 240 Hz (DP 1.4) 144 Hz (HDMI 2.0) Response Time (GtG) 0.03 ms (GtG) Brightness (Typ.) 450 cd/m² (10 % APL) Peak Brightness (HDR) 1000 cd/m² (3 % APL) Color Gamuts RGB 100% (CIE1931) / DCI-P3 99% (CIE1976) Color Accuracy Delta E < 2 Display Colors 1.07Billion HDR Certification VESA DisplayHDR™ True Black 400 Sync Technology Adaptive-Sync Contrast Ratio 1,500,000:1 (Typical) Color Depth 10-bit Connectivity 1 × DisplayPort 1.4 2 × HDMI 2.0 1 × 3.5 mm Audio Out 4x USB 3.2 Gen1 Ergonomics Height: 130 mm Tilt: –5 ° ~ 23 ° Swivel: –30 ° ~ 30 ° Pivot: –90 ° ~ 90 ° Bezel 3-sided frameless Special Features Flicker-Free, Low Blue Mode, Gaming Modes (FPS/Racing/RTS/Gamer1–3), Shadow Control, Game Color, Dial Point, Sniper Scope, Low Input Lag Get the AOC Q27G4ZD 27" QD-OLED at the link below: AOC Q27G4ZD 27" QD OLED Gaming Monitor, 3-Year Zero-Bright-Dot: $427.69 (Sold and Shipped by Amazon US) This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • But even when it says local, it is not local, they all send info back. I bet if you unplug your computer from the net, they would not work Not saying that AI can't do useful stuff, just I don't want it pushed onto me all the flipping time
  • Recent Achievements

    • Week One Done
      MIghty Haul earned a badge
      Week One Done
    • One Month Later
      MIghty Haul earned a badge
      One Month Later
    • Collaborator
      KD2004 earned a badge
      Collaborator
    • One Month Later
      ataho31016 earned a badge
      One Month Later
    • One Month Later
      Delahenty Machinery earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      594
    2. 2
      Michael Scrip
      200
    3. 3
      ATLien_0
      192
    4. 4
      +FloatingFatMan
      140
    5. 5
      Xenon
      127
  • Tell a friend

    Love Neowin? Tell a friend!