By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

Reflection question: type name in shared method

P: n/a
Hi all,

This is driving me crazy: I am trying to get the name of a child class from
a parent class - the catch is that it's in a shared method. Here is what I
have so far:

Public Class Parent
Public Shared Sub Foo()
' I need to get the child name here, but
' since I can't use the "Me" keyword
' i am having problems

'// This fails because of "Me"
Dim ClassName as String = Me.GetType.Name
End Sub

Public Sub NonSharedMethod( )
'In a non-shared method, here is how I would do it:
Dim ClassName as String = Me.GetType.Name
End Sub
End Class

Public Class Child : Inherits Parent
Public Shared Sub bar( )
Call Foo( )
End Sub
End Class
Thanks,
Jeremy
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
After a quick look I found:

System.Reflection.MethodInfo.GetCurrentMethod.Decl aringType()

But there's probably a much more elegant way. Just check out
System.Reflection

HTH,

Jonas


Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.