|
-
Jan 15th, 2008, 07:54 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] how to find derived class name
say i have a class 'MainClass'
now i have another class, 'Class1' and I inherit from 'MainClass' in this class.
for example:
public class Class1
inherits MainClass
end class
Is there a way that i can get the name of this class 'MainClass' that I've inherited from in 'Class1' ? i want to know if it is 'MainClass' that this class is inheriting from.
Basically, i want to be able to find out what the base classes are that my class inherits from.
-
Jan 15th, 2008, 08:02 PM
#2
Re: how to find derived class name
You should be able to adapt this to do what you need:
vb.net Code:
Private Sub ListInheritenceChain(ByVal obj As Object) Dim t As Type = obj.GetType() Do MessageBox.Show(t.Name) If t Is GetType(Object) Then Exit Do Else t = t.BaseType End If Loop End Sub
-
Jan 15th, 2008, 08:21 PM
#3
Addicted Member
Re: how to find derived class name
thanks. but what i am doing is getting class names from an external application. E.g, when I click the first button, all windows in my desktop will be listed. And if I select 1 from the list, say for example, I selected NOTEPAD and clicked the next button, then all the class names from notepad should be listed from the next listbox. I think the one you gave me will only work for the application alone
-
Jan 15th, 2008, 08:24 PM
#4
Re: how to find derived class name
 Originally Posted by iehjsucker
thanks. but what i am doing is getting class names from an external application. E.g, when I click the first button, all windows in my desktop will be listed. And if I select 1 from the list, say for example, I selected NOTEPAD and clicked the next button, then all the class names from notepad should be listed from the next listbox. I think the one you gave me will only work for the application alone
Are you the same person with two accounts?
-
Jan 15th, 2008, 08:45 PM
#5
-
Jan 15th, 2008, 08:58 PM
#6
Thread Starter
Fanatic Member
Re: [RESOLVED] how to find derived class name
thanks very much, jmcilhinney,
that works for me.
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
|