Consider offering C# analog of Rust let repeated_array = [0; 256]
#9515
Replies: 2 comments 10 replies
-
A core concern we had when looking at this is how trivial it is to get things wrong. for example Having a comma/semicolon have such a dramatic effect on meaning is something we did not like. That said, we could roll this into the https://github.com/dotnet/csharplang/blob/main/proposals/collection-expression-arguments.md proposal. While we only support collection expr args for apis using |
Beta Was this translation helpful? Give feedback.
-
I think top-level In the other hand, inserting a sequence into larger collection expression is more useful, for example |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Collection expressions are nice but there doesn't seem to be a good way to say "give me a 256 element array". I've hit this issue many times. It's not so bad when using arrays. It's more jarring when the alternative is
stackalloc
.Here's what's supported today.
It would be very nice to have symmetric syntax that covered the classic scenario, like Rust has.
Beta Was this translation helpful? Give feedback.
All reactions