473,412 Members | 5,714 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,412 software developers and data experts.

Trouble figuring out reflection(?) and recursion

you
Hiya!
I am having some trouble figuring out how to use reflection in a
specific way and was wondering if anyone could help. I hope that I can
explain what I am trying to do clearly so bear with me. I am trying to
teach myself .net as a hobby so is what I am doing isn't the correct way
to do it please let me know. My curiosity would still like to know how
to go about it in the way that I am thinking or I could end up in the
nut-house.

Ok here it is.

Lets say that I have 10 different classes based on an interface. Within
those classes is the possibillity of one or more of its members to be of
the type of any other of the classes.

So far I have something like;

ISomeInterface
SpecificMethod as boolean
End Interface

SomeClass1
Implements ISomeInterface
Member1 as string
Member2 as Integer
Member3 as SomeClass5
SpecificMethod as boolean _
Implements ISomeInterface.SpecificMathod
End Class

SomeClass2...
SomeClass3...
SomeClass4...

SomeClass5
Implements ISomeInterface
Member11 as string
Member21 as Integer
Member31 as SomeClass10
SpecificMethod as boolean _
Implements ISomeInterface.SpecificMathod
End Class

SomeClass6...
SomeClass7...
SomeClass8...
SomeClass9...

SomeClass10
Implements ISomeInterface
Member12 as string
Member22 as Integer
Member32 as SomeClass3
SpecificMethod as boolean _
Implements ISomeInterface.SpecificMathod
End Class
Ok, hope I haven't lost ya yet. So now I have an object (or
whatever it should be called) that is a jumble of my classes. Say
something like;

MyCluster as New MyClass1

with all the sub-class objects created and added and what not.

Now that I have this, how could I recurse through those classes and\or
members based on my interface and run the SpecificMethod for each?

Something like;

SubOrFuntion RunThis(input as ISomeInterface)
Debug.Writeline(input.SpecificMethod.ToString)
For each Thingy in input
If Thingy is somehow compared to ISomeInterface Then
RunThis(Thingy)
End If
Next Thingy
End SubOrFunction

Whew, my brain hurts just thinking about it. I tried using GetType on
Thingy as well as some other thing that I have found on msdn but I
haven't been able to get the results that I am looking for.

Thanks for any help that you can offer.

Jason

Nov 21 '05 #1
0 895

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: drs | last post by:
Hi, I am trying to find all lists of length x with elements a, b, and c. To this end, I have created the class below, but it is not quite working and I am having trouble figuring out what to...
3
by: csx | last post by:
Hi all, Ive got a problem with recursion in Javascript. For this tree: http://www.pcm.uklinux.net/structure.jpg If you input node 3 (i.e. C) which is represented as 'values' in the array, it...
43
by: Lorenzo Villari | last post by:
I've tried to transform this into a not recursive version but without luck... #include <stdio.h> void countdown(int p) { int x;
0
by: Frank Rizzo | last post by:
How can I do deep reflection on an object. In other words, if a property of an object is another object, I want to do reflection on that too and so on until I arrive at value types (or string). ...
75
by: Sathyaish | last post by:
Can every problem that has an iterative solution also be expressed in terms of a recursive solution? I tried one example, and am in the process of trying out more examples, increasing their...
11
by: inihility | last post by:
This is actaully a really simple recursion (for-loop), but I'm having some trouble optimizing it so that it would run faster. for (int i = 0; i < 50; i++) { a = getNumber(i); } Right now it...
3
by: JWest46088 | last post by:
Hello everybody. I'm having a little trouble using recursion. I need to accept input from the user and display the input in a square. It has to be done recursively. I would be able to do it...
1
by: dhettlinger | last post by:
I'm attempting to write some SQL code in Oracle 10g to pull data from a tree structure. Basically, I have a users table, and each user is assigned to a manager. (The user's manager's ID is kept in...
35
by: Muzammil | last post by:
int harmonic(int n) { if (n=1) { return 1; } else { return harmonic(n-1)+1/n; } } can any help me ??
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.