Edit

Share via


Utils.DictionaryToString<T1,T2> Method

Definition

Returns a human-readable text string that describes a dictionary that maps objects to objects.

public static string DictionaryToString<T1,T2> (System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<T1,T2>> dict, Func<T2,string> toString = default, string separator = default);
public static string DictionaryToString<T1,T2> (System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<T1,T2>> dict, Func<T2,string?>? toString = default, string? separator = default);
static member DictionaryToString : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<'T1, 'T2>> * Func<'T2, string> * string -> string
Public Function DictionaryToString(Of T1, T2) (dict As ICollection(Of KeyValuePair(Of T1, T2)), Optional toString As Func(Of T2, String) = Nothing, Optional separator As String = Nothing) As String

Type Parameters

T1

The type of the dictionary keys.

T2

The type of the dictionary elements.

Parameters

dict
ICollection<KeyValuePair<T1,T2>>

The dictionary to describe.

toString
Func<T2,String>

Converts the element to a string. If none specified, ToString() will be used.

separator
String

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.

Applies to