Accessing object property as string and setting its value
- by ludicco
Hello there,
I have an object in csharp from the class Account
each account have a owner, reference, etc.
One way I can access an accounts properties is through accessors like
account.Reference;
but I would like to be able to access it using dynamic string selectors like:
account["PropertyName"];
just like in javascript.
so I would have account["Reference"] which would return the value...but I also would like to be able to sign a new value after that like:
account["Reference"] = "124ds4EE2s";
I've noticed I can use
DataBinder.Eval(account,"Reference")
to get a property based on a string, but using this I can't sign a value to the property.
Any idea on how I could do that?
Thanks a lot