Why does GetFields() not return anything?

c#

Solution

You haven't got public fields. They are properties. So try `type.GetProperties()` instead.

Problem

I am trying to retrieve the public properties of an object but it is returning nothing. Can you tell me what I'm doing wrong. ``` public class AdHocCallReportViewModel : ReportViewModel { public string OperatorForCustEquipID { get; set; } public string OperatorForPriorityID { get; set; } public string OperatorForCallTypeID { get; set; } public string OperatorForStatusID { get; set; } } public UpdateReportParameters(AdHocCallReportViewModel rvm) { var type = rvm.GetType(); foreach (var f in type.GetFields().Where(f => f.IsPublic)) { Console.WriteLine(f.Name); Console.WriteLine(f.GetValue(rvm).ToString()); } } ``` When stepping through the code, it skips over the foreach loop because GetFields returns zero items.

Original source