As in the tile: overriding ToString() on the a KeyValuePair<> struct (System.Collections.Generic).I’m wondering if this can be done at all in C# (sealed structs).
Could anyone provide some insight or alternative approaches?
Or should I simply forget overriding and go for the following:
class MyKeyValuePair
{
public KeyValuePair<T> Pair { get; set; }
public MyKeyValuePair(KeyValuePair<T> pair)
{
this.Pair = pair;
}
public override ToString()
{
...
}
}
No.
You cannot modify existing types, and
structs cannot be inherited.