Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
257 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...