for each property in object c#

C#
foreach (PropertyInfo propertyInfo in obj.GetType().GetProperties())
{
   // do stuff here
}
Source

Also in C#: