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

Dim instance As Nullable(Of T) Dim returnValue As String returnValue = instance.ToString
HasValue プロパティが true の場合は、現在の Nullable オブジェクトの値のテキスト形式。HasValue プロパティが false の場合は空の文字列 ("")。


現在の Nullable オブジェクトの値を表示するコード例を次に示します。
' This code example demonstrates the ' Nullable<T>.ToString method. Imports System Class Sample Public Shared Sub Main() Dim nullableDate As Nullable(Of DateTime) ' Display the current date and time. nullableDate = DateTime.Now Display("1)", nullableDate) ' Assign null (Nothing in Visual Basic) to nullableDate, then ' display its value. nullableDate = Nothing Display("2)", nullableDate) End Sub 'Main ' Display the text representation of a nullable DateTime. Public Shared Sub Display(ByVal title As String, _ ByVal dspDT As Nullable(Of DateTime)) Dim msg As String = dspDT.ToString() Console.Write("{0} ", title) If String.IsNullOrEmpty(msg) Then Console.WriteLine("The nullable DateTime has no defined value.") Else Console.WriteLine("The current date and time is {0}.", msg) End If End Sub 'Display End Class 'Sample 'This code example produces the following results: ' '1) The current date and time is 4/19/2005 8:28:14 PM. '2) The nullable DateTime has no defined value. '
// This code example demonstrates the // Nullable<T>.ToString method. using System; class Sample { public static void Main() { DateTime? nullableDate; // Display the current date and time. nullableDate = DateTime.Now; Display("1)", nullableDate); // Assign null (Nothing in Visual Basic) to nullableDate, then // display its value. nullableDate = null; Display("2)", nullableDate); } // Display the text representation of a nullable DateTime. public static void Display(string title, DateTime? dspDT) { string msg = dspDT.ToString(); Console.Write("{0} ", title); if (String.IsNullOrEmpty(msg)) Console.WriteLine("The nullable DateTime has no defined value."); else Console.WriteLine("The current date and time is {0}.", msg); } } /* This code example produces the following results: 1) The current date and time is 4/19/2005 8:28:14 PM. 2) The nullable DateTime has no defined value. */

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


Weblioに収録されているすべての辞書からNullable.ToString メソッドを検索する場合は、下記のリンクをクリックしてください。

- Nullable.ToString メソッドのページへのリンク