AssemblyName.ToString 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回組件的完整名稱,也稱為顯示名稱。
public:
override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
傳回
組件的完整名稱,如果無法判斷組件的完整名稱,則為類別名稱。
範例
下列範例會取得 AssemblyName 假設元件的 物件 MyAssembly.exe
,然後使用 ToString 方法來擷取完整的元件名稱或顯示名稱。
#using <system.dll>
using namespace System;
using namespace System::Reflection;
int main()
{
// Replace the string "MyAssembly.exe" with the name of an assembly,
// including a path if necessary. If you do not have another assembly
// to use, you can use whatever name you give to this assembly.
//
AssemblyName^ myAssemblyName = AssemblyName::GetAssemblyName( "MyAssembly.exe" );
Console::WriteLine( "\nDisplaying assembly information:\n" );
Console::WriteLine( myAssemblyName );
}
using System;
using System.Reflection;
public class AssemblyName_GetAssemblyName
{
public static void Main()
{
// Replace the string "MyAssembly.exe" with the name of an assembly,
// including a path if necessary. If you do not have another assembly
// to use, you can use whatever name you give to this assembly.
//
AssemblyName myAssemblyName = AssemblyName.GetAssemblyName("MyAssembly.exe");
Console.WriteLine("\nDisplaying assembly information:\n");
Console.WriteLine(myAssemblyName.ToString());
}
}
Imports System.Reflection
Public Class AssemblyName_GetAssemblyName
Public Shared Sub Main()
' Replace the string "MyAssembly.exe" with the name of an assembly,
' including a path if necessary. If you do not have another assembly
' to use, you can use whatever name you give to this assembly.
'
Dim myAssemblyName As AssemblyName = AssemblyName.GetAssemblyName("MyAssembly.exe")
Console.WriteLine(vbCrLf & "Displaying assembly information:" & vbCrLf)
Console.WriteLine(myAssemblyName.ToString())
End Sub
End Class
備註
如需傳回字串的格式,請參閱 的描述 AssemblyName 。