Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 如何修改可空类型';s值多少?_C# 4.0_Nullable - Fatal编程技术网

C# 4.0 如何修改可空类型';s值多少?

C# 4.0 如何修改可空类型';s值多少?,c#-4.0,nullable,C# 4.0,Nullable,导致以下错误: public partial class L2SEntity { public void Scale(double d) { if (this.Amount.HasValue) this.Amount.Value *= d; } } 无法将错误2属性或索引器'System.Nullable.Value'分配给--它是只读的 如何更改金额的(双重类型?)值?直接分配即可 Error 2 Property or in

导致以下错误:

public partial class L2SEntity {
    public void Scale(double d) {
        if (this.Amount.HasValue)
            this.Amount.Value *= d;
    }
}
无法将错误2属性或索引器'System.Nullable.Value'分配给--它是只读的

如何更改金额的(双重类型?)值?

直接分配即可

Error   2   Property or indexer 'System.Nullable<double>.Value' cannot be assigned to -- it is read only

或者一个太少的
{
:-)已更正。
public partial class L2SEntity {
    public void Scale(double d) {
        if (this.Amount.HasValue) {
            this.Amount *= d;
        }
    }
}