Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

AssemblyName.ToString Method

Returns the full name of the assembly, also known as the display name.

[Visual Basic]
Overrides Public Function ToString() As String
[C#]
public override string ToString();
[C++]
public: String* ToString();
[JScript]
public override function ToString() : String;

Return Value

A String that is the full name of the assembly, or the class name if the full name of the assembly cannot be determined.

Remarks

See the description of AssemblyName for the format of the returned string.

Example

[Visual Basic] 
Imports System
Imports System.Reflection
Imports System.Text.RegularExpressions
Imports Microsoft.VisualBasic

Public Class AssemblyName_GetAssemblyName
   
   Public Shared Sub Main()
      

      ' Get the type of 'System.Object'.
      Dim myType As Type = GetType(System.Object)
      
      ' Get the path of 'System.dll'.
      Dim system As String = Regex.Replace(myType.Assembly.CodeBase, "mscorlib.dll", "System.dll")
      system = Regex.Replace(system, "file:///", "")
      
      ' Get the assembly information and display to the console.
      Dim myAssemblyName As AssemblyName = AssemblyName.GetAssemblyName(system)
      Console.WriteLine(ControlChars.Cr + "Displaying the assembly information of 'System.dll'" + ControlChars.Cr)
      Console.WriteLine(myAssemblyName.ToString())
   End Sub 'Main 
End Class 'AssemblyName_GetAssemblyName 

[C#] 

using System;
using System.Reflection;
using System.Text.RegularExpressions;

public class AssemblyName_GetAssemblyName
{
   public static void Main()
   {


      // Get the type of 'System.Object'.
      Type myType = typeof(System.Object);
      
      // Get the path of 'System.dll'.
      string system = Regex.Replace(myType.Assembly.CodeBase, "mscorlib.dll", "System.dll");
      system = Regex.Replace(system, "file:///", "");

      // Get the assembly information and display to the console.
      AssemblyName myAssemblyName = AssemblyName.GetAssemblyName(system);
      Console.WriteLine("\nDisplaying the assembly information of 'System.dll'\n");
      Console.WriteLine(myAssemblyName.ToString());
   }
}

[C++] 

#using <mscorlib.dll>
#using <system.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::Text::RegularExpressions;

int main()
{
   // Get the type of 'System::Object'.
   Type* myType = __typeof(System::Object);

   // Get the path of 'System.dll'.
   String* system = Regex::Replace(myType->Assembly->CodeBase, S"mscorlib.dll", S"System.dll");
   system = Regex::Replace(system, S"file:///", S"");

   // Get the assembly information and display to the console.
   AssemblyName* myAssemblyName = AssemblyName::GetAssemblyName(system);
   Console::WriteLine(S"\nDisplaying the assembly information of 'System.dll'\n");
   Console::WriteLine(myAssemblyName);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

AssemblyName Class | AssemblyName Members | System.Reflection Namespace

Show:
© 2015 Microsoft