[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Reflection - URGENT

Posted on 2007-10-09
Medium Priority
Last Modified: 2013-11-07
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);

but I cannot get value of the dictionary since ClassB is private!!
Question by:DrAske
LVL 96

Accepted Solution

Bob Learned earned 2000 total points
ID: 20041616
Did you try PropertyInfo instead of FieldInfo?


Author Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question