|
-
Apr 16th, 2004, 03:17 AM
#1
Thread Starter
Frenzied Member
How to return reference??
I have a really tricky problem, here is the deal:
I have a method that need to perform certain things based on the type of the object I pass as parameter. I pass an interface where I have a method called "getmytype" where I return "image", "text" etc etc
NOW in this function I need to get the instance of the object that the interface is implemented with. Can this be done?
Is there another way to solve it?
The problems start with that I have an arraylist of 5 different kinds of objects.
Then I have a loop that will interate through all these and get information from the objects. And depending on what kind of object it is, different properties have to be accessed. That is why I need to distinguish them so I can check the type, because when I access them from the arraylist they are of type "object". Then I perform a directcast to the interface and pass that to the function.
Perhaps I have solved this in a bad way? By all means suggest improvements how I can design this in a better way. Im happy to explain it in further detail if needed...
kind regards
Henrik
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|