Build a string from collection content. Each collection item is used to produce a 'key=value' string. Pairs are separated by a semi colon. - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IDictionary

Description

Build a string from collection content. Each collection item is used to produce a 'key=value' string. Pairs are separated by a semi colon.

Demo Code


using System.Text;
using System.Collections.Generic;
using System;//w ww.  ja  v  a 2s. c  om

public class Main{
        /// <summary>Build a string from collection content. Each collection item is used to produce
      /// a 'key=value' string. Pairs are separated by a semi colon.</summary>
        public static string DumpToString(Dictionary<string, string> value)
        {
            var xSB = new StringBuilder();
            foreach (string xKey in value.Keys)
            {
                xSB.AppendFormat("{0}={1};", xKey, value[xKey]);
            }
            return xSB.ToString();
        }
}

Related Tutorials