Windows silverlight 8.1 中的地理坐标 class

Geocordinate class in Windows silverlight 8.1

我刚刚开始在 windows silverlight 8.1 应用程序中使用地图控件 我正在关注 this link,但在 CoordinateConverter Class 中遇到错误 作为

Operator '??' cannot be applied to operands of type 'double' and 'double'

在线

geocoordinate.Altitude ?? Double.NaN

请告诉我这是什么?这是为了什么目的??使用运算符。我该怎么办。

代码在我这边编译得很好,确保你包含了教程中的正确命名空间。


?? 回答你的其他问题:

?? 只是 Nullable Types 的幻想状态

例如

int? x = null;   // notice the ? after the "int"

// Set y to the value of x if x is NOT null; otherwise,
// if x = null, set y to -1.
int y = x ?? -1;

所以在教程中,他们只是通过创建一个新的 GeoCoordinate 来将 Geocoordinate 转换为 GeoCoordinate Geocoordinate.

...

geocoordinate.Altitude ?? Double.NaN;

...

表示如果参数不为 NULL 则使用 geocoordinate.Altitude 否则在创建新对象时使用 Double.Nan