Since C# v3 you have been able to initialise collections leaving a trailing comma…
List<int> vals = new List<int>
{
1,
2,
3,
4,
5,
};
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…
1 comment:
Did you know this made as such to make the life of a gode generator easier. Works the same for enums.
Post a Comment