Skip to content

Instantly share code, notes, and snippets.

@enisn
Created May 7, 2020 20:40
Show Gist options
  • Save enisn/68a45da9b5d898e4bc4948d0d2762a8a to your computer and use it in GitHub Desktop.
Save enisn/68a45da9b5d898e4bc4948d0d2762a8a to your computer and use it in GitHub Desktop.
Challenge #2 - Solution - 3
var user = new User { Name = "John", Email = "[email protected]", Surname = "Doe" /* ... */};
var properties = user.GetType().GetProperties();
foreach(var property in properties)
{
Console.WriteLine(property.Name + " : " + property.GetValue(user));
}
/*
OUTPUT for given object
Name : John
Email : [email protected]
Surname : Doe
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment