Closed FreeApophis closed 1 year ago
Maybe offer a refactoring...
IEnumerable<int> numbers = Sequence.Return(0, 1, 2)
IEnumerable<int> numbers = [0, 1, 2]
One advantage that Sequence.Return
has over collection literals is that it doesn't need a target type. This is useful when invoking extension methods:
[1, 2, 3].Select(x => 2 * x); // error CS9176: There is no target type for the collection expression.
Sequence.Return(1, 2, 3).Select(x => 2 * x) // Works!
I think I will close the issue for now.
There are currently quite a few places where we cannot easily replace the call.
For the other places we might want an analyzer: #762
https://twitter.com/davidfowl/status/1701449085784592888