Skip to content

Utils.DictionaryToString(ICollection<KeyValuePair<T1, T2>>, Func<T2, string?>, string?)

DictionaryToString(ICollection<KeyValuePair<T1, T2>>, Func<T2, string?>, string?)

static
View source
public static string DictionaryToString<T1, T2>(ICollection<KeyValuePair<T1, T2>> dict, Func<T2, string?>? toString = null, string? separator = null)
Returns a human-readable text string that describes a dictionary that maps objects to objects.

Parameters

dictICollection<KeyValuePair<T1, T2>>
The dictionary to describe.
toStringFunc<T2, string?>
Converts the element to a string. If none specified, System.Object.ToString will be used.
separatorstring?
The separator to use. If none specified, the elements should appear separated by a new line.

Returns

A string assembled by wrapping the string descriptions of the individual pairs with square brackets and separating them with commas. Each key-value pair is represented as the string description of the key followed by the string description of the value, separated by " -> ", and enclosed in curly brackets.