2
shouts

Refactor to Array Initializer

posted by KodefuGuruKodefuGuru 281 days, 1 hour, 40 minutes ago
Wednesday, June 10, 2009 5:42:36 PM GMT

Taking advantage of language features can make sleeker, easier to maintain code. One of these language features are array initializers.

Have you ever created an array, then assigned each element in the array? This incurs many lines of code with no tangible benefit. Check out this code from the NameMangler class in LINQ to XSD. char[] splitters = newchar[4];

splitters[0]='/';

splitters[1]='.';

splitters[2]=':';

splitters[3]='-';

string[] pieces = xsdNamespace.Split(splitters);

Th...

category: Agile | clicked: 1 | | source: www.kodefuguru.com | show counter code
tags: C#, Refactor, Refactoring

No comments yet, be the first one to post comment.

To post your comment please login or signup