Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

vb.net - VB how to access the properties of the class by the name?

I do have a class ClientClass with multiple properties. Each object loads client's data from the database. There are also two arrays PropertyName and DBField, which I use as dictionary to get each property (assume all values are strings for simplicity).

client is an object of ClientClass and clientrecord is a recordset - a record in DB table

in short I would like to go through my properties and assign them values from DB like

Public Class ClientClass
    Public person_name As String
    Public person_lastname As String
    Public person_middlename As String

    Public person_firmFlag As String
    Public person_firmName As String
End Class

// then in the code:
for i=1 to n 'n is a number of properties
client.{property(propertyname(i)).value}=clientrecord.Fields(DBFields(i)).value.tostring
next i

what is the proper way to address properties of client object in this case?

thanks!

question from:https://stackoverflow.com/questions/65829452/vb-how-to-access-the-properties-of-the-class-by-the-name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...