Raymond,
Ok, what I thought I had figured out isn't working. Can anyone tell me why
my lenght for propertyinfo always comes up zero?
Because your GetProperties call is returning only members that have only the
Public attribute set. At the very least you also need to include
BindingFlags.Instance if you want instance properties & possible
BindingFlags.Static if you want Shared properties. Be certain to read the
Type.GetProperties(bindingFlags) help to find out how to call it. I would
simply use Type.GetProperties().
However I have a few questions comments about your code:
Shared Function ReflectPropertyNamesToArrayList(ByVal type As Type, _
ByRef al As ArrayList) As ArrayList
Why return the array via both the parameters & the return value?
I would change the function to:
Shared Function ReflectPropertyNamesToArrayList(ByVal type As Type _
) As ArrayList
Dim al As New ArrayList
Note ArrayList is a Reference type, passing it as ByRef is redundent. ByRef
allows ReflectPropertyNamesToArrayList to modify the _al variable itself,
the ArrayList object itself is automatically modifiable by virtue of being a
Reference type.
Why are you calling ToString on a String property?
al.Add(currentProperty.Name.ToString)
I would change it to (as Name is already a string).
al.Add(currentProperty.Name)
Why are you creating an instance of the ArrayList, just to ignore it when
you call ReflectPropertyNamesToArrayList?
I would not use the New keyword on the declaration of _al:
Public Class Retrieve
Dim _al As ArrayList
_al =
PdfSupport.ReflectPropertyNamesToArrayList(GetType(MyClass))
Hope this helps
Jay