I can create a new class with a fully qualified name like Namespace.OuterClass.NestedClass
. But attempting to get the type with Type.GetType(\"Namespace.
String values for C# fully qualified names use +
between classes. Get the type by string with Type.GetType("Namespace.OuterClass+NestedClass")
.
MSDN documentation for Type.GetType(string) gives a syntax table for various types (generic types, arguments, unmanaged pointers, etc.) including "parent class and a nested class".
Adding these lines to the question's sample code:
string typeName1 = typeof(Sample.Program.Vegetable).FullName;
string typeName2 = typeof(Vegetable).FullName;
will prove the string type name equal to Sample.Program+Vegetable
ECMA-335 Partition IV's associated CLILibrary.xml provides the definitive details for this convention. The Type.GetType(string)
syntax table in ECMA-335 is identical to that used in the MSDN documentation.