Difference between double? and double variable
Created at 15 Jan 2016, 09:55
Difference between double? and double variable
15 Jan 2016, 09:55
@ /api/reference/robot/modifypositionasync
a double? variable is used.
What is the difference between double? and regular double variable?
Can a double? variable take null value?
Is this expression correct?
double? stopLoss = null;
double? takeProfit = null;
ModifyPositionAsync (position, stopLoss, takeProfit);
Thanks in advance.
Best regards.
public TradeOperation ModifyPositionAsync(Position position, double? stopLoss, double? takeProfit, [optional] Action callback)
var position = Positions.Find("myLabel", Symbol, TradeType.Buy); if (position != null) { double? stopLoss = Symbol.Ask- 10*Symbol.PipSize; double? takeProfit = Symbol.Ask + 10 * Symbol.PipSize; ModifyPositionAsync(position, stopLoss, takeProfit); }
ozan
15 Jan 2016, 10:44
found the answer @ http://stackoverflow.com/questions/15491889/how-to-assign-null-value-to-non-nullable-type-variable-in-c
How to assign Null value to Non-Nullable type variable in C#?
You have to declare it as a nullable type:
Non nullable types like double can not be null
@ozan