returns the elements of the array as a string, delimited with the default delimitor

image_pdfimage_print
   
 
//CruiseControl is open source software and is developed and maintained by a group of dedicated volunteers. 
//CruiseControl is distributed under a BSD-style license.
//http://cruisecontrol.sourceforge.net/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace ThoughtWorks.CruiseControl.Core.Util
{
    /// <summary>
    /// Class with handy stirng routines
    /// </summary>
    public class StringUtil
    {

        /// <summary>
        /// returns the elements of the array as a string, delimited with the default delimitor
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public static string GetArrayContents(Array x)
        {
            System.Text.StringBuilder result = new System.Text.StringBuilder();

            string DEFAULT_DELIMITER = ",";
            foreach (object o in x)
            {
                result.AppendFormat("{0}{1} ", o.ToString(), DEFAULT_DELIMITER);
            }

            if (result.Length > 0)
            {
                result.Length -= 2;
            }

            return result.ToString();

        }
    }
}

   
     


This entry was posted in Data Types. Bookmark the permalink.