Nullable Struct : Nullable « Data Type « C# / CSharp Tutorial






using System;

struct Point                                    
{
   public int x;                                   
   public int y;                                   

   public Point(int xVal, int yVal)             
   {
      x = xVal; 
      y = yVal;
   }
}

class MainClass
{
   static void Main()
   {
      Point p = new Point(6, 11);     
      Point? nullablePoint  = new Point(5, 10);     

      Console.WriteLine("p.x: {0}", p.x);
      Console.WriteLine("p.y: {0}", p.y);

      Console.WriteLine("nullablePoint.x: {0}", nullablePoint.Value.x);
      Console.WriteLine("nullablePoint.y: {0}", nullablePoint.Value.y);
   }

}
p.x: 6
p.y: 11
nullablePoint.x: 5
nullablePoint.y: 10








2.54.Nullable
2.54.1.null unification
2.54.2.Nullable long
2.54.3.Nullable Struct
2.54.4.Nullable Types Access: Explicitly use properties
2.54.5.Nullable Types Access: shortcut syntax
2.54.6.Nullable Types Assignment
2.54.7.Null Coalescing Operator
2.54.8.A nullable type
2.54.9.Use nullable objects in expressions: result contains null, because one operand is null
2.54.10.Assign value to nullable int
2.54.11.Using ??