As I asked at title,
Is it possible to set a dynamically created property name from database or from an external value in C#?
If yes then how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Typically, the best way to handle this is to store the value within a
Dictionary<string, object>(or evenDictionary<string, dynamic>, or some other class as a value). This provides you a way to use a “dynamic property name” (the key) along with a value.While a custom
DynamicObjectwill allow you to add dynamic members at runtime based on an external source, using those properties becomes problematic, as you don’t know how to refer to them from your code.EDIT: code example: