c# - Reflection to find nested class? -


I have found a class that looks like this:

  public class I want to search subclass by using parent (public square subclass {}}  

and reflection

  void main {parent p = new parent () ; Type t = p.GetType (); Type s = t.GetNestedType ("subclass"); // s is not set}  

This does not work because there are no nested types, how do I get the type of subclass? I need to be found later to call GetMethod ("some method"). come on to her.

I tried only one thing, and it worked for me:

  ParentClass {Public Square NestedClass {}} Private Zero Button 1_Click (Object Sender, EventArgs e) {Type T = Typhon (Parent Class); Type T2 = T. Get Nosted Type ("Nested Class"); MessageBox.Show (t2.ToString ()); }  

Are you sure NestedClass is public?


Comments