?? 的用法在 .NET 1.1中是不支持的。以下两段代码是等同的:
1
Object a
=
null
;
2 object b = a ?? string .Empty;
2 object b = a ?? string .Empty;
1
object
b;
2 if ( a == null )
3 {
4 b = string .Empty;
5 }
6 else
7 {
8 b = a;
9 }
2 if ( a == null )
3 {
4 b = string .Empty;
5 }
6 else
7 {
8 b = a;
9 }
也就是说: 在用a 赋值给 b的时候,如果a是null,就将 'string.Empty'赋值给b,否则还是用a赋值给b。