, , , :
static class KeyValuePairMethods
{
public static String ToCustomString<TK, TV>(this KeyValuePair<TK, TV> kvp)
{
return String.Format("{0}: {1}", kvp.Key, kvp.Value);
}
}
:
new KeyValuePair<string, int>("Hello", 12).ToCustomString();
From the external course course, the ToString () method will still be used, so this probably will not bring you anything.
source
share