.Append not working
Created at 25 Mar 2024, 17:21
.Append not working
25 Mar 2024, 17:21
Hello,
I have the following code:
//make a list of all BUYs
allBuys = Positions.Where(p => p.TradeType == TradeType.Buy);
//get the BUY with the highest price
var last_in = allBuys.OrderByDescending(x => x.EntryPrice).First();
//make another list of positions
var buyBundle = new[] { last_in };
//when I try this, nothing is added to buyBundle
var to_add = allBuys.OrderByDescending(x => x.EntryPrice).Last();
buyBundle.Append(to_add);
Is there something wrong with the declaration of buyBundle? Or where is the error? The compiler doesn't throw any errors.
Thank you,
Dinu
polepole
25 Mar 2024, 21:38
[SOLVED]
The correct code is
buyBundle = buyBundle.Append(to_add).ToArray();
@polepole