troubleshooting Question

How to obtain the values of all the properties in an object

Avatar of Merlin_UK
Merlin_UK asked on
Visual Basic.NET
4 Comments1 Solution338 ViewsLast Modified:
I'm trying to obtain all the values of all the properties of an object (class) and can find the names of the properties without a problem, but  I'm having trouble getting the values of the properties

I've tried the following

    Public Sub test()
        Dim col As PropertyDescriptorCollection = TypeDescriptor.GetProperties(myCustomClass)
        Dim cNew As PropertyDescriptor
        For Each cls As PropertyDescriptor In col
            Dim sName As String = cls.Name
            Dim oValue As Object = cls.GetValue(cls).ToString
    End Sub

But keep getting errors on GetValue()

Any help would be appreciated.
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros