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.

December 2025

S M T W T F S
 1 2 3 4 5 6
7 8910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 8th, 2025 07:29 pm
Powered by Dreamwidth Studios