Convert a list to comma separated string without loop

I have a list with string values. I want to store all values from my list to a variable with comma separated without using loop.

Thanks!

Hello, @kadiravan_kalidoss! This can be made using some vb.net code and some specific methods. Just take a look over these:
VB.NET Convert List to String - Dot Net Perls
vb.net - Convert List of String to a String separated by a delimiter - Stack Overflow
Basically, this should work:

String.Join(",", myListOfStrings.ToArray())

I think I did this at a certain point, if those links don’t help you just let me know and I can actually look for it and find the solution when I have a bit of time.

6 Likes

it works flawlessly…!

Same way can we convert a datatable column values to comma separated string? Without using loop!

1 Like

Awesome that it worked! For datatable column values to a string without using a loop you can also use a line of vb.net code:

dataTable.AsEnumerable().[Select](Function(x) x("Column1").ToString()).Aggregate(Function(a, b) String.Concat(a, "," & b))

Let me know if it works for you!

2 Likes

Thank you !!
its working fine…!

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.