Type.ToString メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As Type Dim returnValue As String returnValue = instance.ToString
現在の Type の名前を表す String。

このメソッドは、共通言語ランタイムの完全限定名前空間とすべてのプリミティブ型の名前を返します。たとえば、C# の命令 (long)0.Type().ToString() では、"Int64" ではなく、"System.Int64" を返します。
現在の Type がジェネリック型を表している場合、型および型引数は名前空間や入れ子にされた型によって修飾されますが、アセンブリには修飾されません。現在の Type がジェネリック型またはジェネリック メソッドの定義の型パラメータを表している場合、このメソッドは型パラメータの非修飾名を返します。

Type の Namespace プロパティと Module プロパティ、および ToString メソッドを使用する例を次に示します。
Imports System Imports Microsoft.VisualBasic Namespace MyNamespace Class [MyClass] End Class '[MyClass] End Namespace 'MyNamespace Public Class Type_ToString_3 Public Shared Sub Main() Try Dim myType As Type = GetType(MyNamespace.MyClass) Console.WriteLine(ControlChars.NewLine + "Printing the details of {0}." + ControlChars.NewLine, myType) ' Get the namespace of the class Type_ToString_3. Console.WriteLine("Namespace: {0}.", myType.Namespace) ' Get the name of the module. Console.WriteLine("Module: {0}.", myType.Module) ' Get the fully qualified common language runtime namespace. Console.WriteLine("Fully qualified type: {0}.", myType.ToString()) Catch e As Exception Console.WriteLine("Exception: " + e.Message.ToString()) End Try End Sub 'Main End Class 'Type_ToString_3
using System; namespace MyNamespace { class MyClass { } } public class Type_ToString_3 { public static void Main() { try { Type myType = typeof(MyNamespace.MyClass); Console.WriteLine("\nPrinting the details of {0}.\n", myType); // Get the namespace of the class Type_ToString_3. Console.WriteLine("Namespace: {0}.", myType.Namespace); // Get the name of the module. Console.WriteLine("Module: {0}.", myType.Module); // Get the fully qualified common language runtime namespace. Console.WriteLine("Fully qualified type: {0}.", myType.ToString()); } catch(Exception e) { Console.WriteLine("Exception: " + e.Message ); } } }
using namespace System; namespace MyNamespace { ref class MyClass{}; } int main() { try { Type^ myType = MyNamespace::MyClass::typeid; Console::WriteLine( "\nPrinting the details of {0}.\n", myType ); // Get the namespace of the class MyClass. Console::WriteLine( "Namespace: {0}.", myType->Namespace ); // Get the name of the module. Console::WriteLine( "Module: {0}.", myType->Module ); // Get the fully qualified common language runtime namespace. Console::WriteLine( "Fully qualified type: {0}.", myType ); } catch ( Exception^ e ) { Console::WriteLine( "Exception: {0}", e->Message ); } }
package MyNamespace; import System.*; class MyClass { } //MyClass public class Type_ToString_3 { public static void main(String[] args) { try { Type myType = MyNamespace.MyClass.class.ToType(); Console.WriteLine("\nPrinting the details of {0}.\n", myType); // Get the namespace of the class Type_ToString_3. Console.WriteLine("Namespace: {0}.", myType.get_Namespace()); // Get the name of the module. Console.WriteLine("Module: {0}.", myType.get_Module()); // Get the fully qualified common language runtime namespace. Console.WriteLine("Fully qualified type: {0}.", myType.ToString()); } catch (System.Exception e) { Console.WriteLine("Exception: " + e.get_Message()); } } //main } //Type_ToString_3

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_Type.ToString メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As _Type Dim returnValue As String returnValue = instance.ToString
現在の Type の名前を表す String。


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- Type.ToStringのページへのリンク