They’re not fields, they’re properties. You can use reflection to list them:
User user = ...
foreach(PropertyInfo prop in typeof(User).GetProperties())
{
Console.WriteLine("{0} = {1}", prop.Name, prop.GetValue(user, null));
}
They’re not fields, they’re properties. You can use reflection to list them:
User user = ...
foreach(PropertyInfo prop in typeof(User).GetProperties())
{
Console.WriteLine("{0} = {1}", prop.Name, prop.GetValue(user, null));
}