Skip to main content

C# get a list of class properties


Just say you wanted to get a list of properties from a class 


var model = new Person();

foreach (var property in model.GetType().GetProperties())

{

   Console.WriteLine(property + " " + property.PropertyType.Name);

}

Comments

Popular posts from this blog