tags:

views:

64

answers:

2

Is it possible to do it? How?
Thank you for your help!

+1  A: 

Use

myType.GetProperties(BindingFlags.NonPublic);

try this link for details.

Vinay B R
This will return an empty array, you also need to specify BindingFlags.Instance or BindingFlags.Static.
Thomas Levesque
+2  A: 

Yes, you can. Specify BindingFlags.NonPublic in your call to GetProperties().

class Program
{
    static void Main(string[] args)
    {
        var f = new Foo();
        foreach (var fi in f.GetType().GetProperties(
                               BindingFlags.NonPublic | BindingFlags.Instance))
        {
            Console.WriteLine(fi);
        }
    }       
}

public class Foo
{
    private string Prop { get; set; }
}
Michael Petrotta