Class Property in for each

Posted by KoolKabin on Stack Overflow See other posts from Stack Overflow or by KoolKabin
Published on 2010-06-15T12:35:52Z Indexed on 2010/06/15 12:42 UTC
Read the original article Hit count: 219

Filed under:
|
|
|

Hi guys,

I am running from a problem while iterating over class properties.

I have my first class:

class Item
  private _UIN as integer = 0
  private _Name as string = ""
  private _Category as ItemCategory = new ItemCategory()

  public Property UIN() as integer
  public property Name() as string
  public property Category() as ItemCategory 

end class

Now when i iterate over the class properties from following code

Dim AllProps As System.Reflection.PropertyInfo()
Dim PropA As System.Reflection.PropertyInfo
dim ObjA as object

AllProps = new Item().getType().getProperties()
for each propA in AllProps
   ObjA = PropA.GetValue(myObj, New Object() {})
   debug.write ObjA.GetType().Name
next

I get UIN, Name, ItemCategory but i expected UIN, Name and Category.

I am a bit unclear about this and dun know why this is happening? What should i do to correct it?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about reflection