Box and unbox for nullable value : nullable « Data Type « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

    class MainClass
    {
        static void Main()
        {
            int? nullable = 5;

            object boxed = nullable;
            Console.WriteLine(boxed.GetType());

            int normal = (int)boxed;
            Console.WriteLine(normal);

            nullable = (int?)boxed;
            Console.WriteLine(nullable);

            nullable = new int?();
            boxed = nullable;
            Console.WriteLine(boxed == null);

            nullable = (int?)boxed;
            Console.WriteLine(nullable.HasValue);
        }
    }








2.58.nullable
2.58.1.Box and unbox for nullable value
2.58.2.Boxing And Unboxing for nullable type
2.58.3.Age Calculation with nullable death date
2.58.4.Convert nullable value to string
2.58.5.Does Nullable value has value
2.58.6.Function for getting Nullable double value
2.58.7.Get hash code for nullable value
2.58.8.Get value or default value for nullable value
2.58.9.Nullable Class Members
2.58.10.Nullable Try Parse
2.58.11.Nullable integer Demo
2.58.12.Nullable value based vector
2.58.13.Partial Comparer for nullable value
2.58.14.Provide default value for nullable value
2.58.15.Reference Compare for nullable value
2.58.16.Using the Nullable Modifier