Quantcast
Channel: User user2023861 - Code Review Stack Exchange
Viewing all articles
Browse latest Browse all 35

Answer by user2023861 for Simple foreach adding to a list

$
0
0

Just use the Concatenation method. That's really what you're doing. You can also use the List constructor that takes an IEnumerable.

var soonestDrawDateModel = new List<SoonestDrawDateModel>(    drawDates.Select(s => new SoonestDrawDateModel()        {            DrawDay = s,            DrawDayId = s.DayId,            CutOffDayId = s.CutOffDayId,        })        .Concat(            drawDates.Select(s => new SoonestDrawDateModel()                {                    DrawDay = s,                    DrawDayId = s.DayId + 7,                    CutOffDayId = s.CutOffDayId,                })        )        .OrderBy(b => b.DrawDayId))

Viewing all articles
Browse latest Browse all 35

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>