Hi i need to obtain the value of attribute of a model by passing the name of attribute like string.
ex
model["ModelID"]
is there any method for this?
thanks
Hi i need to obtain the value of attribute of a model by passing the name of attribute like string.
ex
model["ModelID"]
is there any method for this?
thanks
Luca, I am going to take a small liberty and rephrase your question for you and then hopefully answer it. So I could be one right or twice wrong..
Hi, I would like to get the value of a an object's property using a string key, similar to
var id=model["ModelId"];
.Is this possible?
to which would answer:
One way is to use the Reflection api.
model.GetType().GetProperty("ModelId").GetValue(model,null);