此方法仅搜索当前程序集实例。name 参数包括命名空间,但不包括程序集。若要搜索某一类型的其他程序集,请使用 Type.GetType 方法重载,该方法重载可选择将程序集显示名称包括在类型名称中。
可使用 Module.GetType 从特定模块检索类型。对包含清单的模块调用 Module.GetType 将不启动对整个程序集的搜索。若要从程序集检索类型,而不管该程序集所在的模块,则必须调用 GetType。
例: MyAssembly.GetType("ClassLibrary2.Class1")
另:MyAssembly.GetTypes()返回的数组的值个数有九个之多(FrameWork2.0),分别如下:
+ (0) {Name = "MyApplication" FullName = "ClassLibrary2.My.MyApplication"} System.Type
+ (1) {Name = "MyComputer" FullName = "ClassLibrary2.My.MyComputer"} System.Type
+ (2) {Name = "MyProject" FullName = "ClassLibrary2.My.MyProject"} System.Type
+ (3) {Name = "MyWebServices" FullName = "ClassLibrary2.My.MyProject+MyWebServices"} System.Type
+ (4) {Name = "ThreadSafeObjectProvider`1" FullName = "ClassLibrary2.My.MyProject+ThreadSafeObjectProvider`1"} System.Type
+ (5) {Name = "Class1" FullName = "ClassLibrary2.Class1"} System.Type
+ (6) {Name = "Resources" FullName = "ClassLibrary2.My.Resources.Resources"} System.Type
+ (7) {Name = "MySettings" FullName = "ClassLibrary2.My.MySettings"} System.Type
+ (8) {Name = "MySettingsProperty" FullName = "ClassLibrary2.My.MySettingsProperty"} System.Type