Feature Request: Type inference for generic instance creation ("Diamond" operator) #1755
-
C# should infer types when creating instances of generic objects. So, instead of typing: List<Dictionary<Dictionary<string, int>, int> myList = new List<Dictionary<Dictionary<string, int>, int>(); we could type: List<Dictionary<Dictionary<string, int>, int> myList = new List<>(); This improves code readability but unlike |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
I want to say there's a proposal that would allow List<Dictionary<Dictionary<string, int>, int> myList = new(); but my search-fu is failing me. |
Beta Was this translation helpful? Give feedback.
-
Oh, here it is, I wasn't aware of that. I think that's exactly this. Though that only talks about fields apparently. We would sure need this with properties and local variables too but I guess this isn't the best place to discuss that. |
Beta Was this translation helpful? Give feedback.
-
The issue is #100 and would cover any place the |
Beta Was this translation helpful? Give feedback.
-
dup of championed #1349 |
Beta Was this translation helpful? Give feedback.
-
@ufcpp Not really, this is full type inference vs partial that's explained in that issue but this seems to be a dupe anyways, right? |
Beta Was this translation helpful? Give feedback.
-
Please close. |
Beta Was this translation helpful? Give feedback.
-
This is one thing I don't like about Java |
Beta Was this translation helpful? Give feedback.
The issue is #100 and would cover any place the
new
expression can be used.