If I have for example one class like
public class User{
public int Id { get; set; }
public int Reputation { get; set; }
public string DisplayName { get; set; }
public DateTime LastAccessDate { get; set; }
public DateTime CreationDate { get; set; }
public string WebSiteUrl { get; set; }
public int Views { get; set; }
public int Age { get; set; }
public int UpVotes { get; set; }
public int downVotes { get; set; }
public string Location { get; set; }
public string AboutMe { get; set; }
}
And I want to iterate through these fields dynamicly, for example to some method which will inspect passed object and it will return to caller its fields.
Is this possible ?
They’re not fields, they’re properties. You can use reflection to list them: