タグ

intとnullに関するlamichのブックマーク (2)

  • null許容値型(Nullable<T> 型)

    概要 通常、「値型」は null 値(無効な値)を取れません。 ところが、データベース等、一部のアプリケーションでは、 値型の通常の(有効な)値と null(無効な値)を取るような型が欲しいときがあります。 そこで、C# 2.0 では、null 許容型(Nullable 型)という特殊な型が用意されました。 Ver. 8.0 C# 8.0 では、参照型についても ? の有無で null の可否を指定する機能が追加されました。 この機能を指して null 許容参照型(nullable reference type)と言ったりします。 この null 許容参照型と区別する意味で、項で説明している機能(C# 2.0 時代には唯一の null 許容型だった)を指して、null 許容値型(nullable value type)と呼ぶこともあります。 ポイント 値型 T に対して、T? をいう書き

    null許容値型(Nullable<T> 型)
  • Nullable value types - C# reference

    A nullable value type T? represents all values of its underlying value type T and an additional null value. For example, you can assign any of the following three values to a bool? variable: true, false, or null. An underlying value type T cannot be a nullable value type itself. Any nullable value type is an instance of the generic System.Nullable<T> structure. You can refer to a nullable value ty

  • 1