2 ms·
This is one case where I really prefer C#'s approach; it supports a shortcut syntax (works on anything which implements IEnumerable and has a public Add method)
by ubernostrum 17y ago
This is one case where I really prefer C#'s approach; it supports a shortcut syntax (works on anything which implements IEnumerable and has a public Add method):
List<int> intList = new List<int>() { 1, 2, 3 };
which involves no anonymous classes or anything of the sort. The compiler merely "expands" it into the following before producing the bytecode:
List<int> intList = new List<int>();
intList.Add(1);
intList.Add(2);
intList.Add(3);
Which is, really, about what I'd expect such a shortcut syntax to do.
- deleted 17y ago[deleted]