Sunday, January 27, 2013

Tip-Convert array to Comma delimited string

I was needed to convert an string array into the comma delimited string and the old way to do that is too with for loop. But I was sure that there should be some ready made function that will do this very easily.

After doing some research I have found string.Join. With the help of this we can easily an array into the comma delimited string.

String.join have two arguments one is separator and other one is either array or enumerable.

Following is a code for that.
namespace ConsoleApplication3
{
    class Program
    {
        static void Main() {
            string[] name = {"Jalpesh", "Vishal", "Tushar", "Gaurang"};
            string commnaDelmietedName = string.Join(",", name);
            System.Console.WriteLine(commnaDelmietedName);
        }
    }
}


Let’s run that example and here is the output as expected.

image

That’s it. Hope you like it. Stay tuned for more..
Share:

3 comments:

  1. Can u explain article Jelph how to handle login on g icon click here on coment area ?

    ReplyDelete
  2. thanks I think you have already got that to login with google plus

    ReplyDelete

Your feedback is very important to me. Please provide your feedback via putting comments.

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews