Target-typed array creation #9145
Unanswered
rampaa
asked this question in
Language Ideas
Replies: 1 comment 5 replies
-
Would like to know if collection expression args could possibly support this. List<int> list = [with(1024)]; // list with capacity? Not quite sure about syntax here but perhaps this could be specialized for arrays? |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Today, we need to create arrays like this:
private KeyValuePair<string, string>[] array = new KeyValuePair<string, string>[1024];
It would be great if we could instead write it in a simpler form, like this:
private KeyValuePair<string, string>[] array = new[1024];
I don't think this would introduce any ambiguity, though I could be wrong. If that's the case, feel free to correct me. As a user, I’d definitely expect the more concise version to just work™, so it's disappointing that it doesn't.
Semi-related discussions and issues: #8992, #100 (comment)
Beta Was this translation helpful? Give feedback.
All reactions