[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.
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
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
Re: how to find derived class name
Quote:
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?
Re: how to find derived class name
nope I am not. why? :)
oh my.. i posted at the wrong place :)
Re: [RESOLVED] how to find derived class name
thanks very much, jmcilhinney,
that works for me.