Following this answer, I'm trying to replicate it and iterate over my CustomerModel properties.
CustomerModel pippo = new CustomerModel();
Type customer = pippo.GetType();
FieldInfo[] fields = customer.GetFields(BindingFlags.Public | BindingFlags.Instance);
When using the debugger, fields
always has a count = 0
but CustomerModel has a lot of public properties I'd like to see in fields. How can I do that? Here's an extract of some properties declared I'd like to see.
[DataMember]
public String Id { get; set; }
[DataMember]
public String LoginName { get; set; }
[DataMember]
public String Password { get; set; }
[DataMember]
public String CreationDate { get; set; }
Perhaps the binding flags are incorrect? I'm new to the use of reflection.