jeudi 18 novembre 2021

Using reflection to retreive a specific element in an array

Lets say I have an array of Addresses

How can I filter addresses based on given string. Example if a property path has Addresss.First(), I want it to display the first element, or Address.Last() the last element.

ex:

var _propertyInfo = case.MainContact.GetType().GetProperty("Addresses");

XPCollection<BillingUnitContactAddress> buAddresses = (XPCollection<BillingUnitContactAddress>)_propertyInfo.GetValue(case.MainContact);

BillingUnitContactAddress buAddress = buAddresses.First(); //dont want to hardcode this




Aucun commentaire:

Enregistrer un commentaire