Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through all properties of an object

Status
Not open for further replies.

rrhandle

Programmer
Dec 26, 2001
193
US
I have a class with many properties. Using VB.NET, how can I loop through all the properties and print out their values?

The only thing worse than being alone, is wishing you were.
 
Does not work in VB. "GetType.GetProperties" throws an error.

The only thing worse than being alone, is wishing you were.
 
So for I have gotten this:
Code:
Dim pr As System.Reflection.PropertyInfo
For Each pr In myCls.GetType().GetProperties()
   Response.Write("Name: " + pr.Name + "<BR>")
Next

This will get the name of each property. As far as getting the value associated with it, that is another problem. Have not figured that out yet. This is way more difficult than it should be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top