PDA

View Full Version : Print all property values of a class



rrhandle
01-12-2006, 08:59 PM
I have a collection of objects. I can successfully loop through the collection, and print the value of any property by explicitly stating the property such as obj.ProductGID will print out the value of the current object's ProductGID property.

Looking for a way to print out the values without having to explicitly stating each one. The code below will print the names of the properties, but I don't know how to get the value.

Can anyone help?



Dim prop As System.Reflection.PropertyInfo
For Each prop In obj.GetType.GetProperties()
Debug.Write(prop.Name & " ^^ ")
Next prop
Debug.WriteLine(vbCrLf)

nikkiH
01-13-2006, 06:40 PM
This might help.
http://www.dotnetjunkies.com/WebLog/imranko/archive/2005/06/28/128536.aspx