【问题标题】:Geocordinate class in Windows silverlight 8.1Windows silverlight 8.1 中的地理坐标类
【发布时间】:2016-03-02 09:52:37
【问题描述】:

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

运算符'??'不能应用于“double”和“double”类型的操作数

上线

geocoordinate.Altitude ?? Double.NaN

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

【问题讨论】:

    标签: c# silverlight windows-phone-8.1 maps


    【解决方案1】:

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


    使用?? 回答您的其他问题:

    ?? 只是 Nullable 类型的一种幻想状态

    例如

    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.Altitude ?? Double.NaN;
    

    ...

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

    【讨论】:

    • 好的..谢谢..我检查了我的代码,我将 GeoCoordinate 对象作为参数传递,而不是 Geocoordinate。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 2014-11-21
    相关资源
    最近更新 更多