Suggestion to Collections #1162
Replies: 6 comments
-
#100 probably relevant here. |
Beta Was this translation helpful? Give feedback.
-
Type expressions such as IList<string> list1 = new List<>();
IList<string> list2 = (IList<>)Activator.CreateInstance(typeof(List<>)); A novice C# programmer might then very well wonder why the first line works, while the second does not. Even to a more experienced programmer, it might not be immediately obvious where generic argument inference will happen, and where it won't happen. In my humble opinion, this kind of ambiguity is unnecessary and should be avoided. It's not worth the few saved keystrokes. VB.NET's I can see the proposed language change introduce the same kind of "deception at first glance". |
Beta Was this translation helpful? Give feedback.
-
@yaakov-h the only issue their is that it doesn't work for abstract types. The example in this post uses an That said, I don't like the proposed syntax of this proposal. This is C# and it should not be ugly. In particular it should not be ugly like Java:smiley: |
Beta Was this translation helpful? Give feedback.
-
@aluanhaddad that would be why I said it was relevant, not a duplicate. 😊 |
Beta Was this translation helpful? Give feedback.
-
@yaakov-h true, I read way too much into your pleasantly terse comment 😉 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
IList<string> MyList = new List<>();
Instead of
IList<string> MyList = new List<string>();
Beta Was this translation helpful? Give feedback.
All reactions