Results 1 to 3 of 3

Thread: Reflection and Class Properties

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Question Reflection and Class Properties

    I want to know if there is a way I can discover all the Properties I have set up in my class using Reflection or something similiar?

    I have Class1 with a property called FirstName, LastName.

    I want to be able to loop through all the properties in my class, kind of like a collection. Is that possible?

    Thanks

  2. #2
    Fanatic Member MetalKid's Avatar
    Join Date
    Aug 2005
    Location
    Green Bay, Wisconsin
    Posts
    534

    Re: Reflection and Class Properties

    Yes it is, assuming that class is in a DLL file. You can open it using Reflection and call the GetProperties() method to pull them out and then loop thru them.
    If your problem is solved, please use the Mark Thread As Resolved under Thread Tools!

    Show Appreciation. Rate Posts!

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Reflection and Class Properties

    E.g.
    vb Code:
    1. Dim properties As PropertyInfo() = GetType(Class1).GetProperties()
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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