Since C# v3 you have been able to initialise collections leaving a trailing comma…
List<int> vals = new List<int>
I was asking students in a recent class if they liked it or not…One said that he didn’t like the final comma as he thought it suggested something was missing…My original reason for liking them was that it meant I could easily add to the list. However one student said he liked them as it meant that if you ever did a source control diff on the different versions the diff would only show one line change as opposed to two. I never thought of that…
Did you know this made as such to make the life of a gode generator easier. Works the same for enums.
Post a Comment