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.

October 2025

S M T W T F S
    1 2 3 4
5 6 7891011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Oct. 7th, 2025 11:09 pm
Powered by Dreamwidth Studios