tag:blogger.com,1999:blog-8263949408347549596.post2865590168765111383..comments2023-10-23T23:19:01.111+02:00Comments on Object-Oriented Software Development: C# Puzzle No.18 (beginner)Wiktor Zychlahttp://www.blogger.com/profile/04420514974154487039noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-8263949408347549596.post-38790982607865180552009-06-30T18:24:19.494+02:002009-06-30T18:24:19.494+02:00Hmm, indeed.
That pointed me to find "Which ...Hmm, indeed.<br /><br />That pointed me to find "Which LINQ extension method returns simple T, not IEnumerable<T>, and I found Aggregate as interesting.<br /><br />Here is what I end up with:<br /><br />string TheArrayString = TheArray.Select(x => x.ToString()).Aggregate((pre,post) => pre+", "+post);<br /><br />Visit my website www.hakger.orgDetohttp://www.hakger.orgnoreply@blogger.comtag:blogger.com,1999:blog-8263949408347549596.post-4851812352679836052009-06-29T21:37:57.312+02:002009-06-29T21:37:57.312+02:00a clue towards more natural solution - Linq can al...a clue towards more natural solution - Linq can also be used to accumulate, not only to select.Wiktor Zychlahttps://www.blogger.com/profile/04420514974154487039noreply@blogger.comtag:blogger.com,1999:blog-8263949408347549596.post-73204925119002172252009-06-29T21:20:05.430+02:002009-06-29T21:20:05.430+02:00okey, I got cheap solution :)
Normally I would u...okey, I got cheap solution :)<br /><br />Normally I would use static string.Join(), and here you have it.<br /><br />..but - if I have to start as you wrote, then :<br /><br />string TheArrayString = TheArray.Select(x => string.Join(", ",TheArray.Select(s => s.ToString()).ToArray())).First();Detohttp://www.hakger.xorg.plnoreply@blogger.com