Results 1 to 3 of 3

Thread: [RESOLVED] for each property in myclassname?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    44

    Resolved [RESOLVED] for each property in myclassname?

    Want to do a simple bit of code that will help me debug some custom classes I'm building, but I can't figure out how to do it.

    All I want to do is console.writeline every property in a class... something like:

    Code:
    dim prop as Property
    dim myclass as new myclassname
    
    for each prop in myclass 
      console.writeline prop.name
      console.writeline prop.value
    next
    Spent two hours searching so far, just easier to ask. Thanks.

  2. #2
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: for each property in myclassname?

    If you look in the System.Interop.Reflection namespace there's a bunch of useful classes for dissecting and enumerating the properties of a class....

    e.g.
    Code:
    Dim DataObjectProperties() As PropertyInfo = MyObject.GetType.GetProperties()
    (Where MyObject is the thingy you want to enumerate)
    Last edited by Merrion; Jul 2nd, 2007 at 02:40 PM. Reason: I keep forgetting the vb tag doesnae work...

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    44

    Re: for each property in myclassname?

    Thanks so much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width