I have a user details class
public partial class UserDetails
    {
        public int? Level { get; set; }
        public string Unit { get; set; }
        public string Bio { get; set; }
        public bool? Gender { get; set; }
        public int? Mobile { get; set; }
        public string Photo { get; set; }
    }
I am writing an update method:
public bool UpdateDetails(string userId, UserProperties updateProperty, string value)
        {
         switch(updateProperty)
            {
                case UserProperties.Unit:
                    details.Unit = value;
                    break;
                case UserProperties.Photo:
                    details.Photo = value;
                    break;
                default:
                    throw new Exception("Unknown User Detail property");
            }
May I do something like dynamic property in JavaScript? e.g.
var details = new UserDetails();
details["Unit"] = value;
Update
As of year 2019! How about try to use this new feature?! DynamicObject DynamicObject.TrySetMember(SetMemberBinder, Object) Method
I am trying to figure out how to write it.
 
     
     
    