Nullable.ToString メソッドとは? わかりやすく解説

Nullable.ToString メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

現在の Nullable オブジェクトの値のテキスト形式返します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説
使用例使用例

現在の 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.

*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からNullable.ToString メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からNullable.ToString メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からNullable.ToString メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Nullable.ToString メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Nullable.ToString メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS