How to enumerate all properties of the object and output them?

  • Thread starter Thread starter GS
  • Start date Start date
G

GS

Hi,

What would be c# code to enumarate all properties of object and output them in a form "property name:value"?

Thanks,
GS
 
Dim txt As New TextBox
Dim type As Type = txt.GetType()
Dim properties() As PropertyInfo = type.GetProperties()
For Each p As PropertyInfo In properties
Response.Write(p.Name & ":" & CStr(p.GetValue(txt, Nothing)))
Response.Write("<br>")
Next

You should read up the documentation on GetProperties, as it accepts a flag-based enumeration that can change the behaviour.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


Hi,

What would be c# code to enumarate all properties of object and output them in a form "property name:value"?

Thanks,
GS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top