c# - Decide property to use at runtime -


itemprop = "text">

There are more than 50 properties in my staff class. I display all property names using the property info square on the checkbox list on the windows form. I do Users can select more than one asset to display in the report The user needs to get all the strings in order to accept the selected name, title, phone, address and display it on the report.

I can easily do it or with the switch but there is no other better way than to write more than 50 switch statements

To get value as well for you (if this is what you mean): < Pre> PropertyInfo propertyInfo = catalog.GetType (). GetProperties (BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHyarchy). Where (x = & gt; x.Name == propertyName) .SingleOrDefault (); Object property value = propertyInfo.GetGetMethod (). Invite (Customer);

Comments