tags:

views:

42

answers:

1
public partial class L2SEntity {
    public void Scale(double d) {
        if (this.Amount.HasValue)
            this.Amount.Value *= d;
    }
}

Results in the following error:

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

How do I change the Amount's (type of double?) value?

+3  A: 

Just assign it directly.

public partial class L2SEntity {
    public void Scale(double d) {
        if (this.Amount.HasValue) {
            this.Amount *= d;
        }
    }
}
tdammers
Oh lollament's. Accepting in 9 minutes.
randomguy
Isn't there 1 too many `}` now in the edited version?
JLWarlow
Or one too few `{`. :-)Corrected.
tdammers