How to concatate string array?

  • Thread starter Thread starter GS
  • Start date Start date
G

GS

Hello,

I have string collection. I want to concatate all collection members using new line character. How do I do that in minimum amount of code?

Thanks
G

myItem.ShipToLocation is String Collection
I'd like to use something like Response.Write (string.Concat(myItem.ShipToLocation.ToArray()) or something but this does not work.
 
How about if I need to concatate Collection not of strings?
For example
myItem.PaymentMethods is object collection and I'd like to join all
myItem.PaymentMethods.toString()
How do I do that
 
You can do something like this


// make an array of strings. Note that we have included spaces
string [] s = { "hello ", "and ", "welcome ", "to ", "this ", "demo!
" };
// put all the strings together
Console.WriteLine(string.Concat(s));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top