473,419 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

An easy method to implent an ICollections interface

110 100+
I was wondering if there is any easy way to implement an IGeneric interface from using a member within that class that already implements all the methods/properties/functions within that IGeneric.

<CODE>
Public Class MyClass
Inherits AnotherClass
Implements IDictionary(Of String, Object)

Dim _DictionaryMember As Dictionary(Of String, Object)

#Region "Methods that implement IDictionary Methods which make blank calls/returns to _DictionaryMember's functions (which already implement all of IDictionary's stuff)"
' That stuff
#End Region

End Class

</CODE>

Without implementing all those wrapper calls from IDictonary to _DictionaryMember. If the solution used templates, that would be acceptable too, so long as I can still inherit AnotherClass.

-I'm a C++ Programmer just getting into Visual Basic .Net, so not having multiple inheritance is painstakingly hard, unless the Interfaces could seamlessly use a member's implemented interfaces.

I would stick with C++, but my companies customer only knows Visual Basic, so after we are finished with the project I'm working on, they will be able to maintain some of the minor issues with our software..
Nov 1 '08 #1
1 1895
TamusJRoyce
110 100+
If this helps, here is a trick we are already using.

I've found through using templates in visual basic.net, you can recursively have your base class know it's type is.

<CODE>
' VB.Net code:
Public MustInherit Class FooClass(Of T As FooClass(Of T))
' Stuff

Public Function HasNotSubroutine (AnItem As T) As Boolean
Return Not T.HasSubroutine()
End Sub
End Class

Public Class AnotherFoo
Inherits FooClass(Of AnotherFoo)

Public Function HasSubroutine() As Boolean
Return True
End Function
End Class
</CODE>

And if I wrote this correctly, after casting AnotherFoo to a FooClass, or when calling directly from AnotherFoo, HasNoSubroutine() will return the opposite of what HasSubroutine() from AnotherFoo calls.
Nov 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: JW | last post by:
I'm displaying product thumbnails with brief descriptions on web pages. Clicking on the product does a javascript popup with larger image and detailed description info passed to the javascript...
0
by: PatchFactory Support | last post by:
Description: Professional and easy-to-use patch building environment that can help you to create instant patch packages for software and file updating. Generated patch packages are small size...
24
by: el_roachmeister | last post by:
Is there a way to make a text link post to a form without passing all the parameters in the url? The urls tend to get very long and messy. I often wonder if there is a limit to how long they can...
11
by: Dave Rahardja | last post by:
OK, so I've gotten into a philosophical disagreement with my colleague at work. He is a proponent of the Template Method pattern, i.e.: class foo { public: void bar() { do_bar(); } protected:...
6
by: Alex Sedow | last post by:
Example 1 interface I { string ToString(); } public class C : I { public void f() {
15
by: jon | last post by:
How can I call a base interface method? class ThirdPartyClass :IDisposable { //I can not modify this class void IDisposable.Dispose() { Console.WriteLine( "ThirdPartyClass Dispose" ); } } ...
4
by: Ray Dukes | last post by:
What I am looking to do is map the implementation of interface properties and functions to an inherited method of the base class. Please see below. ...
4
by: Johnny Drama | last post by:
Let's say I have an interface IScope: internal interface IScope{} ....and I have a class that implements IScope: internal class Scope:IScope{} .... and I have a method that returns...
4
by: David Zha0 | last post by:
Hi, "when we call a virtual method, the runtime will check the instance who called the method and then choose the suitable override method, this may causes the performance drop down", is this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.