I have a helper manager with following properties:
public class ClientDetails
{
public string ContactName { get; set; }
public string ContactTelephone { get; set; }
public string Add1 { get; set; }
public string Add2 { get; set; }
public string Town { get; set; }
public string PostCode { get; set; }
}
I want to 'get' all these properties in one method. Something like:
protected string ContactDetails(string propertyName)
{
var _clientDetails = ManagerHelper.ClientDetails();
var temp = typeof (ClientDetails);
var value = temp.GetProperty(propertyName);
return value.GetValue(_clientDetails); //ERROR
}
I have read somewhere that you can use reflection to do these kind of things but I'm not familiar with reflection. I have tried using reflection above however it gives me an error on _clientDetails.
So if I call this method like string address1 = ContactDetails("Add1")
then it returns me the value in ClientDetails().Add1
.
Error is "No overload for method 'GetValue takes 1 arguments".