Author: sashee | Posted on: 12/1/2008 8:06:32 PM | Views : 485

Hi: 

I am having a problem while using the reflection. Here is the scenario:

mainClass
-Field1
-Field2
-innerClass

innerClass
-Field3
-Field4

I need to get the value of 'Field4' at runtime while having an instance of mainClass in hand.

here is what I am doing:

propInfo prop1 = objMainClass.GetType().GetProperty("objInnerClass");
propInfo prop2 = prop1.PropertyType.GetProperty("Field4");

for getting value:

prop2.GetValue(objMainClass,null)

I need to cast 'objMainClass' to 'mainClass.innerClass' type. How should I achieve that? could anyone please direct me? Thanks.

~sashee
...

Go to the complete details ...