6 public static void Main(String
[] args
) {
7 Console
.WriteLine("Note that null prints as blank or []\n");
8 bool? b1
= null, b2
= false, b3
= true;
9 bool? b4
= b1^b2
, b5
= b1
&b2
, b6
= b1
|b2
; // null false null
10 Console
.WriteLine("[{0}] [{1}] [{2}]", b4
, b5
, b6
);
11 bool? b7
= b1^b3
, b8
= b1
&b3
, b9
= b1
|b3
; // null null true
12 Console
.WriteLine("[{0}] [{1}] [{2}]", b7
, b8
, b9
);
13 Console
.WriteLine(b1
!= null ? "null is true" : "null is false"); // null is false
14 Console
.WriteLine(b1
== null ? "!null is true" : "!null is false"); // !null is false
17 bool?[] bvals
= new bool?[] { null, false, true }
;
18 Console
.WriteLine("{0,-6} {1,-6} {2,-6} {3,-6} {4,-6}",
19 "x", "y", "x&y", "x|y", "x^y");
20 foreach (bool? x
in bvals
)
21 foreach (bool? y
in bvals
)
22 Console
.WriteLine("{0,-6} {1,-6} {2,-6} {3,-6} {4,-6}",
25 Console
.WriteLine("{0,-6} {1,-6}", "x", "!x");
26 foreach (bool? x
in bvals
)
27 Console
.WriteLine("{0,-6} {1,-6}", x
, !x
);