Implicit Type conversion for generics in instance declaration #2689
Unanswered
80O
asked this question in
Language Ideas
Replies: 2 comments
-
In the case of a variable, I would just use For a field, you can use target-typed |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 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.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm proposing to have implicit type conversion in instance declaration for generics like Java.
For example:
LinkedList<string> names = new LinkedList<string>();
Becomes:
LinkedList<string> names = new LinkedList<>();
I often find myself wondering why C# does not allow this and needs explicitly the type declared in the new instance while it can be inferred from the type declaration already.
The <> should be required as otherwise the type is different and no longer generic.
Beta Was this translation helpful? Give feedback.
All reactions