Share via


Type.AssemblyQualifiedName 属性

获取 Type 的程序集限定名,其中包括从中加载 Type 的程序集的名称。

**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public MustOverride ReadOnly Property AssemblyQualifiedName As String
用法
Dim instance As Type
Dim value As String

value = instance.AssemblyQualifiedName
public abstract string AssemblyQualifiedName { get; }
public:
virtual property String^ AssemblyQualifiedName {
    String^ get () abstract;
}
/** @property */
public abstract String get_AssemblyQualifiedName ()
public abstract function get AssemblyQualifiedName () : String

属性值

Type 的程序集限定名,其中包括从中加载 Type 的程序集的名称;或者为 空引用(在 Visual Basic 中为 Nothing)(如果当前实例表示泛型类型参数)。

备注

所有支持公共语言运行库的编译器将发出嵌套类的简单名称,并且在接受查询时,反射将依照下列约定构造一个重整名称。

分隔符

含义

反斜杠 (\)

转义符。

逗号 (,)

位于程序集名称前。

加号 (+)

位于嵌套类前。

句点 (.)

表示命名空间标识符。

中括号 ([])

在类型名称之后,表示该类型的数组。

- 或 -

对于泛型类型,则括起泛型类型实参列表。

- 或 -

在类型实参列表中,则括起程序集限定的类型。

例如,某个类的程序集限定的名称可能类似如下:

TopNamespace.SubNameSpace.ContainingClass+NestedClass, MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089

如果命名空间包含一个加号,例如 TopNamespace.Sub+Namespace,则在加号 (+) 前面将附加一个转义字符 (\) 以防止将它解释为嵌套分隔符。反射将按如下形式发出此字符串:

TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3.0.0, Culture=neutral, PublicKeyToken=b17a5c561934e089 

“++”变成“\+\+”,而“\”变成“\\”。

可以保持此限定名并在以后使用它来加载 Type。若要搜索和加载 Type,请只结合类型名或者结合程序集限定类型名使用 GetType。只结合类型名时,GetType 将只在调用方的程序集中查找 Type,然后再在系统程序集中查找。结合程序集限定类型名时,GetType 将在所有程序集中查找 Type

类型名可能包含尾部字符,尾部字符表示有关该类型的附加信息,如类型是引用类型、指针类型还是数组类型。若要检索不具有这些尾随字符的类型名称,请使用 t.GetElementType().ToString(),其中 t 为类型。

在除程序集名称之外的所有类型名称组成部分中,空格都相关。在程序集名称中,“,”分隔符之前的空格相关,但“,”分隔符之后的空格将被忽略。

泛型类型的泛型参数本身由程序集名称限定。例如,在 MyGenericClass<int>(在 Visual Basic 中为 MyGenericClass(Of Integer))的程序集限定类型名中,int 扩展为 Int32 的程序集限定类型名。

如果当前 Type 对象表示泛型参数,则此属性返回 空引用(在 Visual Basic 中为 Nothing)。

示例

下面的示例显示与类关联的程序集名和类型的完全限定名。

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
Class MyAssemblyClass
    Public Shared Sub Main()
        Dim objType As Type = GetType(System.Array)
        ' Print the full assembly name.
        Console.WriteLine("Full assembly name: {0}.", objType.Assembly.FullName.ToString())
        ' Print the qualified assembly name.
        Console.WriteLine("Qualified assembly name: {0}.", objType.AssemblyQualifiedName.ToString())
    End Sub 'Main
End Class 'MyAssemblyClass
using System;
using System.Reflection;

class MyAssemblyClass
{

    public static void Main()
    {
        Type objType = typeof(System.Array);
                    
        // Print the full assembly name.
        Console.WriteLine ("Full assembly name: {0}.", objType.Assembly.FullName.ToString()); 

        // Print the qualified assembly name.
        Console.WriteLine ("Qualified assembly name: {0}.", objType.AssemblyQualifiedName.ToString()); 
    }
}
using namespace System;
using namespace System::Reflection;
int main()
{
   Type^ objType = System::Array::typeid;
   
   // Print the full assembly name.
   Console::WriteLine( "Full assembly name: {0}.", objType->Assembly->FullName );
   
   // Print the qualified assembly name.
   Console::WriteLine( "Qualified assembly name: {0}.", objType->AssemblyQualifiedName );
}
import System.*;
import System.Reflection.*;

class MyAssemblyClass
{
    public static void main(String[] args)
    {
        Type objType = System.Array.class.ToType();
        // Print the full assembly name.
        Console.WriteLine("Full assembly name: {0}.",
            objType.get_Assembly().get_FullName().ToString());
        // Print the qualified assembly name.
        Console.WriteLine("Qualified assembly name: {0}.",
            objType.get_AssemblyQualifiedName().ToString());
    } //main
} //MyAssemblyClass

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0

请参见

参考

Type 类
Type 成员
System 命名空间
String 类
GetType
FullName
Namespace
AssemblyName

其他资源

指定完全限定的类型名称