mercredi 10 juin 2015

Get private property of a private property using reflection?

public class Foo
{
    private Bar FooBar {get;set;}

    private class Bar
    {
        private string Str {get;set;}
        public Bar() {Str = "some value";}
    }
 }

If I've got something like the above and I have a reference to Foo, how can I use reflection to get the value FooBar out Foo's Bar? I know there's no actual reason to ever do something like this (or very very few ways), but I figure there has to be a way to do it and I can't figure out how to accomplish it.





Aucun commentaire:

Enregistrer un commentaire