how do I iterate through internal properties in c#

You need to specify that you don't just need the public properties, using the overload accepting BindingFlags:

foreach (PropertyInfo property in typeof(TestClass)
             .GetProperties(BindingFlags.Instance | 
                            BindingFlags.NonPublic |
                            BindingFlags.Public))
{
    //do something
}

Add BindingFlags.Static if you want to include static properties.

The parameterless overload only returns public properties.


You need to change the BindingFlags on your call to Type.GetProperties

Try:

var instanceProperties = typeof(TestClass).GetProperties(
    BindingFlags.Public |
    BindingFlags.NonPublic | 
    BindingFlags.Instance
);
foreach(var instanceProperty in instanceProperties) {
    // a little something something for the instanceProperty
}

According to MSDN, private and internal are not recognized in Reflection API.

To identify an internal method using Reflection, use the IsAssembly property. To identify a protected internal method, use the IsFamilyOrAssembly.

If You are writing some test units You might want to take a look at InternalsVisibleTo attribute. It allows you to specify which assembly can see internal properties.

And finally, do You really need to have internal properties...