Andy's observations as he continues to attempt to know all that is .NET...

Wednesday, June 03, 2009

Trailing comma in C#

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…

1 comment:

zproxy said...

Did you know this made as such to make the life of a gode generator easier. Works the same for enums.

About Me

My photo
Im a freelance consultant for .NET based technology. My last real job, was at Cisco System were I was a lead architect for Cisco's identity solutions. I arrived at Cisco via aquisition and prior to that worked in small startups. The startup culture is what appeals to me, and thats why I finally left Cisco after seven years.....I now filll my time through a combination of consultancy and teaching for Developmentor...and working on insane startups that nobody with an ounce of sense would look twice at...