Reflection - URGENT

Posted on 2007-10-09
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

    Did you try PropertyInfo instead of FieldInfo?

    LVL 9

    Author Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now