gpt4 book ai didi

c# - 将 nullable double 设置为 null 有什么问题?

转载 作者:可可西里 更新时间:2023-11-01 07:53:18 26 4
gpt4 key购买 nike

<分区>

Possible Duplicates:
Why can't I set a nullable int to null in a ternary if statement?
Nullable types and the ternary operator. Why won't this work?

下面有什么问题

public double? Progress { get; set; }
Progress = null; // works
Progress = 1; // works
Progress = (1 == 2) ? 0.0 : null; // fails

Type of conditional expression cannot be determined because there is no implicit conversion between 'double' and '<null>'

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com