Convert Dictionary to String : Generic Collections « Generics « C# / C Sharp






Convert Dictionary to String

   
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PSAdmin.Core.Utils
{
    public static class DictionaryExtensions
    {
        public static string ConvertToString(this IDictionary<string, object> dict) {
            string result = string.Empty;
            if (dict != null) {
                foreach (var v in dict) {
                    result += string.Format("{0}={1}\n", v.Key, v.Value.ToString());
                }
            }
            return result;
        }
    }
}

   
    
    
  








Related examples in the same category

1.Generic Collection and List
2.Add user-defined object to generic Collection
3.Add Collection Items with IComparable interface implementation
4.Sort by Name
5.Add object in a hierarchy into a generic Collection
6.Generic collection class
7.Represents a generic collection of key/value pairs. The enumerator returns the values in the order assigned.
8.List To String
9.String list and String set