ConvertToString() public static method

Converts a dictionary of object, object to a string representation in the form of Key=Valueseparator.
public static ConvertToString ( object>.IDictionary dictionary, string separator ) : string
dictionary object>.IDictionary The dictionary.
separator string The separator to separate key value pairs.
return string
Example #1
0
        public void ConvertDictionaryToString()
        {
            IDictionary <object, object> dictionary = new Dictionary <object, object>();

            dictionary.Add("bla", "haha");
            dictionary.Add(1, 25);
            dictionary.Add("exception", new Exception("exception"));

            string s = FormatHelper.ConvertToString(dictionary, "; ");

            s.Should().Be("bla=haha; 1=25; exception=System.Exception: exception");
        }
Example #2
0
        public void ConvertCollectionToString()
        {
            string s = FormatHelper.ConvertToString(new object[] { 3, "hello", new Exception("exception") }, ", ");

            s.Should().Be("3, hello, System.Exception: exception");
        }