Marco,
Because "BindingFlags.DeclaredOnly" is "used to change how the search
works", which means you need to include other BindingFlags to actually
define the search, such as BindingFlags.Public to include public members,
also you need at least BindingFlags.Instance or BindingFlags.Static to say
if you want instance members or include Shared members also...
Try something like:
Dim flags As BindingFlags = BindingFlags.Instance _
Or BindingFlags.Public _
Or BindingFlags.DeclaredOnly
Dim myMembers As System.Reflection.MemberInfo()
=myClass.GetType.GetMembers(flags)
For details see:
http://msdn.microsoft.com/library/de...bersTopic2.asp
Hope this helps
Jay
"Marco" <ma***@support.endurance.it> wrote in message
news:8b******************@tornado.fastwebnet.it...
Hi,
I try to use reflection to retrieve class B members and not inherited
members. I wonder why the myMember value is nothing. Any suggestions?
Thanks
Module Module1
Sub Main()
Dim myClass As B = New B
Dim myMembers As System.Reflection.MemberInfo() =
myClass.GetType.GetMembers(Reflection.BindingFlags .DeclaredOnly)
End Sub
End Module
Class A
Public a1 As Integer
Public a2 As Integer
End Class
Class B
Inherits A
Public b1 As Integer
End Class