using System;
using System.Collections;
using System.Collections.Generic;
namespace Csharp
{
class Program
{
static void Main(string[] args)
{
int? a = null;
int? b = a + 4; //b=null
int? c = a * 5; //c=null
Console.WriteLine(a);
Console.WriteLine(b);
Console.WriteLine(c);
Console.ReadKey();
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
namespace Csharp
{
class Program
{
static void Main(string[] args)
{
int? a = null;
int? b = -5;
//在比较可空类型时,只要有一个操作数是null,比较的结果就是false
//即不能因为一个条件是false,就认为该条件的对立面是true,这在使用非可空类型的程序中很常见
if (a <= b)
Console.WriteLine("a<=b");
else
Console.WriteLine("a<b");
Console.WriteLine(a);
Console.WriteLine(b);
Console.ReadKey();
}
}
}