I have a class as
public class Customer
{
public string Name {get; set;}
public string Email {get;set;}
//etc.
}
Somewhere in my application, I need to access these properties & to save myself from hardcoding property names, I am thinking to try something like the below but not finding any way to do so.
public string Get(string propertyName,string value)
{
_customersList.SingleOrDefault(x => x.[propertyName] == value)
}
How can I access the customer properties dynamically or say by argument name?
Thanks!