How do I create delimited value from an array?

Category: System, viewed: 225 time(s).

If you want to create a delimited string value out of an array you can use the string.Join() method. The Join method we use below accept two parameters. The delimiter character use to delimiting one value from the other which is the comma symbol and the source information to be delimited, which is the array.

The Join method will return a single string that concatenate all the values in the array delimited with the delimiter symbol.

using System;

namespace Kodecsharp.Example.System
{
    public class StringDelimitedCreate
    {
        public static void Main(string[] args)
        {
            string[] numbers = { "1", "1", "2", "3", "5", "8", "13" };

            //
            // Creating a delimited value of the numbers array and use
            // comma symbol as the delimiter.
            //
            string delimitedValue = string.Join(",", numbers);

            Console.WriteLine("Delimited Value: " + delimitedValue);
            Console.ReadLine();
        }
    }
}
Download Hundreds of Complimentary Industry Resources

Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more; all available at no cost to you. With more than 600 complimentary offers, you'll find plenty of titles to suit your professional interests and needs. Click Here and Sign up today!

Our Friends

Statistics

Locations of visitors to this page