andrewducker: (Default)
[personal profile] andrewducker
The code I've been writing to convert a list into a comma-delimited string that consists of:
var duckerBrothers = new List<string> { "Andy", "Mike", "Hugh" };
var output = string.Empty;
foreach (var duckerBrother in duckerBrothers)
{
if (output != string.Empty)
{
output += ", ";
}

output += duckerBrother;
}

Can be rewritten as:
var duckerBrothers = new List<string> { "Andy", "Mike", "Hugh" };
var output = string.Join(",", duckerBrothers);

That's what I get for assuming that there is no built-in way of doing things.

Date: 2013-01-15 07:13 pm (UTC)
akicif: Slightly 'shopped stonehenge pic, summer solstice 2001 (Default)
From: [personal profile] akicif
Ha! Of course. Clearly the real reason I'm not a coder is my eye for detail....

November 2025

S M T W T F S
       1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 272829
30      

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Nov. 28th, 2025 01:32 am
Powered by Dreamwidth Studios