NeuralJack Posted September 26, 2007 Posted September 26, 2007 (edited) Hi what is the mechanism for which I could use to add functions to lists of certain classes? I'm guessing that there is one. So I want these lists to have some of the same functions: List (of Class1) List (of Class2) List (of Class3) The specific functions I'd want to add are like: .GetObjectFromName .GetIndexFromName So Each of Class1, Class2, and Class3 have a variable named "Name" I know about how to use interfaces but I'm not sure about how add an interface with a pre-existing class or collection object. Thanks Edited September 26, 2007 by NeuralJack Quote Currently Using: Visual Basic.Net 2005, .Net Framework 2.0
Administrators PlausiblyDamp Posted October 1, 2007 Administrators Posted October 1, 2007 Just to clarify a couple of things... Firstly each of the classes expose the same methods (or a least some of the methods are the same) that need to be moved to an interface - correct? Secondly you would like to be able to create a generic List object that could contain any of these objects - also correct? If so you would just need to define a new interface that contains the relevant methods and get each of your existing classes to implement this interface. This will probably require a little bit of editing in VB to make sure each of the existing methods is followed by the relevant Implements statement as well... Generics can be restricted to classes that implement a particular Interface as explained by marble_eater in this post Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.