Are you sure? I think Where() works as lazy/deferred as most LINQ operators do. That means inside a LINQ chain, Where() will only request the next item from the operator "above" when an operator "below" requested an item from it.
In contrast, operators like GroupBy() and OrderBy() do in fact evaluate the complete enumerable befor they can yield their first item. Which makes sense, because both have to look at all items, before they can determine the grouping/ordering.
Are you sure? I think
Where()
works as lazy/deferred as most LINQ operators do. That means inside a LINQ chain,Where()
will only request the next item from the operator "above" when an operator "below" requested an item from it.In contrast, operators like
GroupBy()
andOrderBy()
do in fact evaluate the complete enumerable befor they can yield their first item. Which makes sense, because both have to look at all items, before they can determine the grouping/ordering.A bit longer but avoids copying the array and sorts it in-place instead.
This is so brilliant it makes me ashamed of my solution :D
Finally another solution that doesn't rely on string conversions/parsing!
Mine looks almost identical ^^
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Oh my god, that's so smart! I love it :)
Unfortunately the C# compiler used does not support C# 8.0 with
switch
expressions.DecodeCharacter()
would look less bulky/noisy with that: