Nice Gem! Building comma-separated string from IEnumerable
Here is a nice Gem. This extension method will allow you to easily build a comma-separated string from an Enumerable list. For example, if you have a list of Customer objects and you need a comma-separated string of all CustomerIds, you just call the CommaSeparate extension method on the list.
Internally we use it a lot to build SQL statements such as
Here is the code (short and sweet):
And, here is an example of how you'd use it on a list of Users.
Walt Lynton, Mar 19, 2010
That was great! Just in need of that, need to save search tags of media user uploads on image server. User uses the same tags to search. Needed to save the in comma separated format. Thanks.
Jun 17, 2010
Yes, it is good one to use
Apr 27, 2010
Really a good one! I will add this to my Extensions library.
Mar 19, 2010
You can already do that with linq.
Taliesin Sisson, Mar 23, 2010