Link to home
Start Free TrialLog in
Avatar of DrAske
DrAskeFlag for Jordan

asked on

Reflection - URGENT

Hi experts ..

I have the following class:

public class ClassA
{
       private class ClassB
       {
                 public string property;
       }
     
       private  IDictionary<string, ClassB> dictionary;
}

How to use reflection to get *property* value of one of the keys in *dictionary* field??

I am getting *dictionary* field as follow:

BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
FieldInfo field = Typeof(ClassA).GetField("dictionary", bindFlags);
feld.GetValue(instance);

but I cannot get value of the dictionary since ClassB is private!!
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DrAske

ASKER

What I want to say that I cannot cast the object obtained from FiledInfo to IDictionary<string, ClassB> since ClassB is a private class!!