How to use Nullable types in c++/cli?

后端 未结 1 604
情深已故
情深已故 2020-12-13 23:42

I have the following code, which I thought would work:

property Nullable Angle {
    Nullable get() {
        return nullptr;
             


        
相关标签:
1条回答
  • 2020-12-14 00:29

    OK, found it, after a lot of hassle:

    to return null, just do

    return Nullable<double>();
    

    to return non-null:

    return Nullable<double>(12321);
    

    It is important to declare the return value as Nullable<double> and not Nullable<double>^, as if you do it, when using other languages as C# and vb.net, you'll see the type as ValueType instead of double?.

    0 讨论(0)
提交回复
热议问题