Module.Name 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 String
,它表示移除了路径的模块名。
public:
virtual property System::String ^ Name { System::String ^ get(); };
public:
property System::String ^ Name { System::String ^ get(); };
public virtual string Name { get; }
public string Name { get; }
member this.Name : string
Public Overridable ReadOnly Property Name As String
Public ReadOnly Property Name As String
属性值
不带路径的模块名。
示例
此示例演示 、 FullyQualifiedName
和 Name
属性的效果ScopeName
。
using namespace System;
using namespace System::Reflection;
int main()
{
Module^ mod = Assembly::GetExecutingAssembly()->GetModules()[ 0 ];
Console::WriteLine( "Module Name is {0}", mod->Name );
Console::WriteLine( "Module FullyQualifiedName is {0}", mod->FullyQualifiedName );
Console::WriteLine( "Module ScopeName is {0}", mod->ScopeName );
}
/*
This code produces the following output:
Module Name is modname.exe
Module FullyQualifiedName is C:\Bin\modname.exe
Module ScopeName is modname.exe
*/
using System.Reflection;
using System;
public class Simple
{
public static void Main ()
{
Module mod = typeof(Simple).Assembly.GetModules () [0];
Console.WriteLine ("Module Name is " + mod.Name);
Console.WriteLine ("Module FullyQualifiedName is " + mod.FullyQualifiedName);
Console.WriteLine ("Module ScopeName is " + mod.ScopeName);
}
}
/*
This code produces output like the following:
Module Name is modname.exe
Module FullyQualifiedName is C:\Bin\modname.exe
Module ScopeName is modname.exe
*/
Imports System.Reflection
Public Class Simple
Public Shared Sub Main()
Dim myMod As System.Reflection.Module =
GetType(Simple).Assembly.GetModules()(0)
Console.WriteLine("Module Name is " + myMod.Name)
Console.WriteLine("Module FullyQualifiedName is " _
+ myMod.FullyQualifiedName)
Console.WriteLine("Module ScopeName is " + myMod.ScopeName)
End Sub
End Class
' This code produces output like the following:
' Module Name is modname.exe
' Module FullyQualifiedName is C:\Bin\modname.exe
' Module ScopeName is modname.exe
注解
Name
是依赖于平台的字符串。
如果此模块的程序集是从字节数组加载的, FullyQualifiedName
则模块的 将为: <Unknown>。
若要获取名称和路径,请使用 FullyQualifiedName。