Is there a way to get a list of innerclasses in C#?

Dr. Thomas C. King picture Dr. Thomas C. King · Apr 6, 2011 · Viewed 11.8k times · Source

As per the title. I'd like a list of all the inner classes of a given class, it can be a list of names or a list of types - I am not fussed. Is this possible? I thought there might be a way using reflection but haven't been able to find one.

Answer

Chris Pitman picture Chris Pitman · Apr 6, 2011

You want Type.GetNestedTypes. This will give you the list of types, which you can then query for their names.